summaryrefslogtreecommitdiff
path: root/tests/utils_tests/test_html.py
diff options
context:
space:
mode:
authorMike Edmunds <medmunds@gmail.com>2024-12-14 15:57:41 -0800
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2024-12-17 10:18:48 +0100
commit322e49ba3071022dde96f6aae71a578a1588db33 (patch)
tree58cfd34dd45388a7b4e91b4dc98631c309ab29a2 /tests/utils_tests/test_html.py
parentb44efdfe543c9b9f12690b59777e6b275cb08103 (diff)
Fixed #36012 -- Made mailto punctuation percent-encoded in Urlizer.
Urlizer was not properly encoding email addresses containing punctuation in generated mailto links. Per RFC 6068, fixed by percent encoding (urllib.parse.quote) the local and domain address parts.
Diffstat (limited to 'tests/utils_tests/test_html.py')
-rw-r--r--tests/utils_tests/test_html.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/utils_tests/test_html.py b/tests/utils_tests/test_html.py
index dc3768e6fa..0beaf98bff 100644
--- a/tests/utils_tests/test_html.py
+++ b/tests/utils_tests/test_html.py
@@ -376,6 +376,19 @@ class TestUtilsHtml(SimpleTestCase):
+ "한.글." * 15
+ "aaa</a>",
),
+ (
+ # RFC 6068 requires a mailto URI to percent-encode a number of
+ # characters that can appear in <addr-spec>.
+ "yes;this=is&a%valid!email@example.com",
+ '<a href="mailto:yes%3Bthis%3Dis%26a%25valid%21email@example.com"'
+ ">yes;this=is&a%valid!email@example.com</a>",
+ ),
+ (
+ # Urlizer shouldn't urlize the "?org" part of this. But since
+ # it does, RFC 6068 requires percent encoding the "?".
+ "test@example.com?org",
+ '<a href="mailto:test@example.com%3Forg">test@example.com?org</a>',
+ ),
)
for value, output in tests:
with self.subTest(value=value):