summaryrefslogtreecommitdiff
path: root/django/utils/html.py
diff options
context:
space:
mode:
authorSaJH <wogur981208@gmail.com>2025-08-27 23:25:43 +0900
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2025-08-28 08:54:56 +0200
commita9fe98d5bd4212d069afe8316101984aadecfbb2 (patch)
tree9ec270af941dd2c2ec6824d3efeedd7c06a267f8 /django/utils/html.py
parent05bac8c4202aba77dcb109aeedd35ff563331e1a (diff)
Fixed #35533 -- Prevented urlize creating broken links given a markdown link input.
Signed-off-by: SaJH <wogur981208@gmail.com>
Diffstat (limited to 'django/utils/html.py')
-rw-r--r--django/utils/html.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/django/utils/html.py b/django/utils/html.py
index d3b904a822..734d7fbfb3 100644
--- a/django/utils/html.py
+++ b/django/utils/html.py
@@ -10,7 +10,7 @@ from urllib.parse import parse_qsl, quote, unquote, urlencode, urlsplit, urlunsp
from django.conf import settings
from django.core.exceptions import SuspiciousOperation, ValidationError
-from django.core.validators import EmailValidator
+from django.core.validators import DomainNameValidator, EmailValidator
from django.utils.deprecation import RemovedInDjango70Warning
from django.utils.functional import Promise, cached_property, keep_lazy, keep_lazy_text
from django.utils.http import MAX_URL_LENGTH, RFC3986_GENDELIMS, RFC3986_SUBDELIMS
@@ -296,7 +296,9 @@ class Urlizer:
simple_url_re = _lazy_re_compile(r"^https?://\[?\w", re.IGNORECASE)
simple_url_2_re = _lazy_re_compile(
- r"^www\.|^(?!http)\w[^@]+\.(com|edu|gov|int|mil|net|org)($|/.*)$", re.IGNORECASE
+ rf"^www\.|^(?!http)(?:{DomainNameValidator.hostname_re})"
+ r"\.(com|edu|gov|int|mil|net|org)($|/.*)$",
+ re.IGNORECASE,
)
word_split_re = _lazy_re_compile(r"""([\s<>"']+)""")