Loading django/core/handlers/wsgi.py +1 −1 Original line number Diff line number Diff line Loading @@ -263,4 +263,4 @@ def get_str_from_wsgi(environ, key, default): """ value = environ.get(str(key), str(default)) # Same comment as above return value if six.PY2 else value.encode(ISO_8859_1).decode(UTF_8) return value if six.PY2 else value.encode(ISO_8859_1).decode(UTF_8, errors='replace') docs/releases/1.7.1.txt +3 −0 Original line number Diff line number Diff line Loading @@ -117,3 +117,6 @@ Bugfixes * Fixed generic relations in ``ModelAdmin.list_filter`` (:ticket:`23616`). * Restored RFC compliance for the SMTP backend on Python 3 (:ticket:`23063`). * Fixed a crash while parsing cookies containing invalid content (:ticket:`23638`). tests/handlers/tests.py +10 −0 Original line number Diff line number Diff line Loading @@ -80,6 +80,16 @@ class HandlerTests(TestCase): # much more work than fixing #20557. Feel free to remove force_str()! self.assertEqual(request.COOKIES['want'], force_str("café")) def test_invalid_unicode_cookie(self): """ Invalid cookie content should result in an absent cookie, but not in a crash while trying to decode it (#23638). """ environ = RequestFactory().get('/').environ environ['HTTP_COOKIE'] = 'x=W\x03c(h]\x8e' request = WSGIRequest(environ) self.assertEqual(request.COOKIES, {}) @override_settings(ROOT_URLCONF='handlers.urls') class TransactionsPerRequestTests(TransactionTestCase): Loading Loading
django/core/handlers/wsgi.py +1 −1 Original line number Diff line number Diff line Loading @@ -263,4 +263,4 @@ def get_str_from_wsgi(environ, key, default): """ value = environ.get(str(key), str(default)) # Same comment as above return value if six.PY2 else value.encode(ISO_8859_1).decode(UTF_8) return value if six.PY2 else value.encode(ISO_8859_1).decode(UTF_8, errors='replace')
docs/releases/1.7.1.txt +3 −0 Original line number Diff line number Diff line Loading @@ -117,3 +117,6 @@ Bugfixes * Fixed generic relations in ``ModelAdmin.list_filter`` (:ticket:`23616`). * Restored RFC compliance for the SMTP backend on Python 3 (:ticket:`23063`). * Fixed a crash while parsing cookies containing invalid content (:ticket:`23638`).
tests/handlers/tests.py +10 −0 Original line number Diff line number Diff line Loading @@ -80,6 +80,16 @@ class HandlerTests(TestCase): # much more work than fixing #20557. Feel free to remove force_str()! self.assertEqual(request.COOKIES['want'], force_str("café")) def test_invalid_unicode_cookie(self): """ Invalid cookie content should result in an absent cookie, but not in a crash while trying to decode it (#23638). """ environ = RequestFactory().get('/').environ environ['HTTP_COOKIE'] = 'x=W\x03c(h]\x8e' request = WSGIRequest(environ) self.assertEqual(request.COOKIES, {}) @override_settings(ROOT_URLCONF='handlers.urls') class TransactionsPerRequestTests(TransactionTestCase): Loading