diff options
| author | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2024-08-12 15:17:57 +0200 |
|---|---|---|
| committer | Natalia <124304+nessita@users.noreply.github.com> | 2024-09-03 09:42:15 -0300 |
| commit | d147a8ebbdf28c17cafbbe2884f0bc57e2bf82e2 (patch) | |
| tree | 490946e5437ffb064fe1f2e655f7e6566d8c7257 /tests | |
| parent | 705066d186ce880bf64142e47084f3d8df3c2352 (diff) | |
[4.2.x] Fixed CVE-2024-45230 -- Mitigated potential DoS in urlize and urlizetrunc template filters.
Thanks MProgrammer (https://hackerone.com/mprogrammer) for the report.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/template_tests/filter_tests/test_urlize.py | 22 | ||||
| -rw-r--r-- | tests/utils_tests/test_html.py | 1 |
2 files changed, 23 insertions, 0 deletions
diff --git a/tests/template_tests/filter_tests/test_urlize.py b/tests/template_tests/filter_tests/test_urlize.py index abc227ba6a..e542802aae 100644 --- a/tests/template_tests/filter_tests/test_urlize.py +++ b/tests/template_tests/filter_tests/test_urlize.py @@ -305,6 +305,28 @@ class FunctionTests(SimpleTestCase): "http://testing.com/example</a>.,:;)"!", ) + def test_trailing_semicolon(self): + self.assertEqual( + urlize("http://example.com?x=&", autoescape=False), + '<a href="http://example.com?x=" rel="nofollow">' + "http://example.com?x=&</a>", + ) + self.assertEqual( + urlize("http://example.com?x=&;", autoescape=False), + '<a href="http://example.com?x=" rel="nofollow">' + "http://example.com?x=&</a>;", + ) + self.assertEqual( + urlize("http://example.com?x=&;;", autoescape=False), + '<a href="http://example.com?x=" rel="nofollow">' + "http://example.com?x=&</a>;;", + ) + self.assertEqual( + urlize("http://example.com?x=&.;...;", autoescape=False), + '<a href="http://example.com?x=" rel="nofollow">' + "http://example.com?x=&</a>.;...;", + ) + def test_brackets(self): """ #19070 - Check urlize handles brackets properly diff --git a/tests/utils_tests/test_html.py b/tests/utils_tests/test_html.py index 83ebe4334b..7ff5020fb6 100644 --- a/tests/utils_tests/test_html.py +++ b/tests/utils_tests/test_html.py @@ -364,6 +364,7 @@ class TestUtilsHtml(SimpleTestCase): "&:" + ";" * 100_000, "&.;" * 100_000, ".;" * 100_000, + "&" + ";:" * 100_000, ) for value in tests: with self.subTest(value=value): |
