From 99dcc59237f384d7ade98acfd1cae8d90e6d60ab Mon Sep 17 00:00:00 2001 From: Justin Thurman Date: Wed, 16 Oct 2024 09:43:02 -0400 Subject: Fixed #35845 -- Updated DomainNameValidator to require entire string to be a valid domain name. Bug in 4971a9afe5642569f3dcfcd3972ebb39e88dd457. Thank you to kazet for the report and Claude Paroz for the review. --- django/core/validators.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'django') diff --git a/django/core/validators.py b/django/core/validators.py index b1c5c053b8..8732ddf7ad 100644 --- a/django/core/validators.py +++ b/django/core/validators.py @@ -101,13 +101,16 @@ class DomainNameValidator(RegexValidator): if self.accept_idna: self.regex = _lazy_re_compile( - self.hostname_re + self.domain_re + self.tld_re, re.IGNORECASE + r"^" + self.hostname_re + self.domain_re + self.tld_re + r"$", + re.IGNORECASE, ) else: self.regex = _lazy_re_compile( - self.ascii_only_hostname_re + r"^" + + self.ascii_only_hostname_re + self.ascii_only_domain_re - + self.ascii_only_tld_re, + + self.ascii_only_tld_re + + r"$", re.IGNORECASE, ) super().__init__(**kwargs) -- cgit v1.3