]> git.ipfire.org Git - thirdparty/jinja.git/commitdiff
don't apply `urlize` to `@a@b` 2062/head
authorнаб <nabijaczleweli@nabijaczleweli.xyz>
Thu, 20 Jul 2023 02:20:13 +0000 (04:20 +0200)
committerDavid Lord <davidism@gmail.com>
Fri, 20 Dec 2024 04:37:58 +0000 (20:37 -0800)
CHANGES.rst
src/jinja2/utils.py
tests/test_utils.py

index 3955a32baf97f471784a47b762738e93f6d744c0..e31de857d3f6e939f9eb56d038efe159b633eab7 100644 (file)
@@ -40,6 +40,7 @@ Unreleased
 -   ``PackageLoader`` shows a clearer error message when the package does not
     contain the templates directory. :issue:`1705`
 -   Improve annotations for methods returning copies. :pr:`1880`
+-   ``urlize`` does not add ``mailto:`` to values like `@a@b`. :pr:`1870`
 
 
 Version 3.1.4
index d7149bc319fbc69896172ef3ffabf8c8bf20f071..7c922629a926c83c55476bd339f6dc32e48a9aec 100644 (file)
@@ -333,6 +333,8 @@ def urlize(
         elif (
             "@" in middle
             and not middle.startswith("www.")
+            # ignore values like `@a@b`
+            and not middle.startswith("@")
             and ":" not in middle
             and _email_re.match(middle)
         ):
index 86e0f0420fc70e59693cb9d62074041432fab50c..b50a6b4c6ab03fccef2f652ccc0b0c6de46db69a 100644 (file)
@@ -142,6 +142,14 @@ class TestEscapeUrlizeTarget:
             "http://example.org</a>"
         )
 
+    def test_urlize_mail_mastodon(self):
+        fr = "nabijaczleweli@nabijaczleweli.xyz\n@eater@cijber.social\n"
+        to = (
+            '<a href="mailto:nabijaczleweli@nabijaczleweli.xyz">'
+            "nabijaczleweli@nabijaczleweli.xyz</a>\n@eater@cijber.social\n"
+        )
+        assert urlize(fr) == to
+
 
 class TestLoremIpsum:
     def test_lorem_ipsum_markup(self):