diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-09-07 11:41:34 -0500 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-09-07 11:47:38 -0500 |
| commit | 65b6eff322a4a3331601e111934dee95c090961c (patch) | |
| tree | 94580fb35090dbafa54203e8cbbdbc3f6cc01ba1 | |
| parent | ff49449425eb9d4d04096f4f1bc4b32158683699 (diff) | |
Fixed #20530 -- Properly decoded non-ASCII query strings on Python 3.
Thanks mitsuhiko for the report.
This commit just adds a test since the problem was fixed in 8aaca651.
| -rw-r--r-- | tests/handlers/tests.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/handlers/tests.py b/tests/handlers/tests.py index 812dd3f22d..f5dc7c8531 100644 --- a/tests/handlers/tests.py +++ b/tests/handlers/tests.py @@ -41,6 +41,16 @@ class HandlerTests(TestCase): response = handler(environ, lambda *a, **k: None) self.assertEqual(response.status_code, 400) + def test_non_ascii_query_string(self): + """Test that non-ASCII query strings are properly decoded (#20530).""" + environ = RequestFactory().get('/').environ + raw_query_string = 'want=café' + if six.PY3: + raw_query_string = raw_query_string.encode('utf-8').decode('iso-8859-1') + environ['QUERY_STRING'] = raw_query_string + request = WSGIRequest(environ) + self.assertEqual(request.GET['want'], "café") + def test_non_ascii_cookie(self): """Test that non-ASCII cookies set in JavaScript are properly decoded (#20557).""" environ = RequestFactory().get('/').environ @@ -49,6 +59,9 @@ class HandlerTests(TestCase): raw_cookie = raw_cookie.encode('utf-8').decode('iso-8859-1') environ['HTTP_COOKIE'] = raw_cookie request = WSGIRequest(environ) + # If would be nicer if request.COOKIES returned unicode values. + # However the current cookie parser doesn't do this and fixing it is + # much more work than fixing #20557. Feel free to remove force_str()! self.assertEqual(request.COOKIES['want'], force_str("café")) |
