don't apply urlize to @a@b

This commit is contained in:
наб 2023-07-20 04:20:13 +02:00 committed by David Lord
parent 106d61cba5
commit 0cd6948192
No known key found for this signature in database
GPG Key ID: 43368A7AA8CC5926
3 changed files with 11 additions and 0 deletions

View 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

View 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)
):

View 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):