diff --git a/CHANGES.rst b/CHANGES.rst index bbfad1356..b71fd0986 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -8,6 +8,7 @@ Unreleased - Use modern packaging metadata with ``pyproject.toml`` instead of ``setup.cfg``. :pr:`1793` - Use ``flit_core`` instead of ``setuptools`` as build backend. +- Don't ``mailto:``-``urlize()`` addresses in the form ``@a@b``. :pr:`1870` Version 3.1.3 diff --git a/src/jinja2/utils.py b/src/jinja2/utils.py index 4b4720f6d..78eb5bdfe 100644 --- a/src/jinja2/utils.py +++ b/src/jinja2/utils.py @@ -324,6 +324,7 @@ def trim_url(x: str) -> str: elif ( "@" in middle and not middle.startswith("www.") + and not middle.startswith("@") and ":" not in middle and _email_re.match(middle) ): diff --git a/tests/test_utils.py b/tests/test_utils.py index 7b58af144..11f76c2eb 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -141,6 +141,14 @@ def test_escape_urlize_target(self): "http://example.org" ) + def test_urlize_mail_mastodon(self): + fr = "nabijaczleweli@nabijaczleweli.xyz\n@eater@cijber.social\n" + to = ( + '' + "nabijaczleweli@nabijaczleweli.xyz\n@eater@cijber.social\n" + ) + assert urlize(fr) == to + class TestLoremIpsum: def test_lorem_ipsum_markup(self):