diff options
| author | Justin Thurman <justin.thurman@bevy.com> | 2024-10-16 09:43:02 -0400 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2024-10-17 16:45:44 +0200 |
| commit | 99dcc59237f384d7ade98acfd1cae8d90e6d60ab (patch) | |
| tree | c738f80bbea3f6487104cd296feb45e9d57cd502 /django/core | |
| parent | 65f3cfce59395131f318cf1ecba144530ed6609e (diff) | |
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.
Diffstat (limited to 'django/core')
| -rw-r--r-- | django/core/validators.py | 9 |
1 files changed, 6 insertions, 3 deletions
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) |
