diff options
| author | Mike Edmunds <medmunds@gmail.com> | 2024-12-14 16:54:42 -0800 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2025-01-23 10:38:15 +0100 |
| commit | 29ba75e6e57414f0e6f9528d08a520b8b931fb28 (patch) | |
| tree | 59757ea3ef4cb0cffa14ee1a499209c83e982110 /tests/template_tests | |
| parent | 23c960a98e0d054d51dadda7049a54a083ef1155 (diff) | |
Fixed #36013 -- Removed use of IDNA-2003 in django.utils.html.
Removed obsolete and potentially problematic IDNA 2003 ("punycode")
encoding of international domain names in smart_urlquote() and Urlizer,
which are used (only) by AdminURLFieldWidget and the urlize/urlizetrunc
template filters. Changed to use percent-encoded UTF-8, which defers
IDNA details to the browser (like other URLs rendered by Django).
Diffstat (limited to 'tests/template_tests')
| -rw-r--r-- | tests/template_tests/filter_tests/test_urlize.py | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/tests/template_tests/filter_tests/test_urlize.py b/tests/template_tests/filter_tests/test_urlize.py index 80dd94cd9f..c186acd948 100644 --- a/tests/template_tests/filter_tests/test_urlize.py +++ b/tests/template_tests/filter_tests/test_urlize.py @@ -229,19 +229,34 @@ class FunctionTests(SimpleTestCase): """ #13704 - Check urlize handles IDN correctly """ + # The "✶" below is \N{SIX POINTED BLACK STAR}, not "*" \N{ASTERISK}. self.assertEqual( urlize("http://c✶.ws"), - '<a href="http://xn--c-lgq.ws" rel="nofollow">http://c✶.ws</a>', + '<a href="http://c%E2%9C%B6.ws" rel="nofollow">http://c✶.ws</a>', ) self.assertEqual( urlize("www.c✶.ws"), - '<a href="http://www.xn--c-lgq.ws" rel="nofollow">www.c✶.ws</a>', + '<a href="http://www.c%E2%9C%B6.ws" rel="nofollow">www.c✶.ws</a>', ) self.assertEqual( - urlize("c✶.org"), '<a href="http://xn--c-lgq.org" rel="nofollow">c✶.org</a>' + urlize("c✶.org"), + '<a href="http://c%E2%9C%B6.org" rel="nofollow">c✶.org</a>', ) self.assertEqual( - urlize("info@c✶.org"), '<a href="mailto:info@xn--c-lgq.org">info@c✶.org</a>' + urlize("info@c✶.org"), + '<a href="mailto:info@c%E2%9C%B6.org">info@c✶.org</a>', + ) + + # Pre-encoded IDNA is urlized but not re-encoded. + self.assertEqual( + urlize("www.xn--iny-zx5a.com/idna2003"), + '<a href="http://www.xn--iny-zx5a.com/idna2003"' + ' rel="nofollow">www.xn--iny-zx5a.com/idna2003</a>', + ) + self.assertEqual( + urlize("www.xn--fa-hia.com/idna2008"), + '<a href="http://www.xn--fa-hia.com/idna2008"' + ' rel="nofollow">www.xn--fa-hia.com/idna2008</a>', ) def test_malformed(self): |
