diff options
| author | Tom Hacohen <tasn@users.noreply.github.com> | 2019-01-04 02:21:55 +0000 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2019-01-03 22:09:25 -0500 |
| commit | 1cd00fcf52d089ef0fe03beabd05d59df8ea052a (patch) | |
| tree | 46439a6356b26ef009283d89871370cec1e0949c /tests | |
| parent | b683bb0c9fec43706e4117ef0d690ab4758d8af0 (diff) | |
[1.11.x] Fixed #30070, CVE-2019-3498 -- Fixed content spoofing possiblity in the default 404 page.
Co-Authored-By: Tim Graham <timograham@gmail.com>
Backport of 1ecc0a395be721e987e8e9fdfadde952b6dee1c7 from master.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/handlers/tests.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/tests/handlers/tests.py b/tests/handlers/tests.py index 29083150a7..b34a7918d4 100644 --- a/tests/handlers/tests.py +++ b/tests/handlers/tests.py @@ -2,6 +2,7 @@ from __future__ import unicode_literals +import sys import unittest from django.core.exceptions import ImproperlyConfigured @@ -19,6 +20,8 @@ try: except ImportError: # Python < 3.5 HTTPStatus = None +PY37 = sys.version_info >= (3, 7, 0) + class HandlerTests(SimpleTestCase): @@ -184,16 +187,17 @@ class HandlerRequestTests(SimpleTestCase): def test_invalid_urls(self): response = self.client.get('~%A9helloworld') - self.assertContains(response, '~%A9helloworld', status_code=404) + self.assertEqual(response.status_code, 404) + self.assertEqual(response.context['request_path'], '/~%25A9helloworld' if PY37 else '/%7E%25A9helloworld') response = self.client.get('d%aao%aaw%aan%aal%aao%aaa%aad%aa/') - self.assertContains(response, 'd%AAo%AAw%AAn%AAl%AAo%AAa%AAd%AA', status_code=404) + self.assertEqual(response.context['request_path'], '/d%25AAo%25AAw%25AAn%25AAl%25AAo%25AAa%25AAd%25AA') response = self.client.get('/%E2%99%E2%99%A5/') - self.assertContains(response, '%E2%99\u2665', status_code=404) + self.assertEqual(response.context['request_path'], '/%25E2%2599%E2%99%A5/') response = self.client.get('/%E2%98%8E%E2%A9%E2%99%A5/') - self.assertContains(response, '\u260e%E2%A9\u2665', status_code=404) + self.assertEqual(response.context['request_path'], '/%E2%98%8E%25E2%25A9%E2%99%A5/') def test_environ_path_info_type(self): environ = RequestFactory().get('/%E2%A8%87%87%A5%E2%A8%A0').environ |
