diff --git a/django/core/validators.py b/django/core/validators.py index 15b16bcd2f..8c43644ed6 100644 --- a/django/core/validators.py +++ b/django/core/validators.py @@ -83,9 +83,10 @@ class URLValidator(RegexValidator): ipv6_re = r'\[[0-9a-f:\.]+\]' # (simple regex, validated later) # Host patterns - hostname_re = r'[a-z' + ul + r'0-9](?:[a-z' + ul + r'0-9-]*[a-z' + ul + r'0-9])?' - domain_re = r'(?:\.(?!-)[a-z' + ul + r'0-9-]+(? 253: + raise ValidationError(self.message, code=self.code) + integer_validator = RegexValidator( _lazy_re_compile('^-?\d+\Z'), message=_('Enter a valid integer.'), diff --git a/docs/releases/1.10.txt b/docs/releases/1.10.txt index 932d53b029..bee3b1d41f 100644 --- a/docs/releases/1.10.txt +++ b/docs/releases/1.10.txt @@ -258,7 +258,9 @@ URLs Validators ^^^^^^^^^^ -* ... +* :class:`~django.core.validators.URLValidator` now limits the length of + domain name labels to 63 characters and the total length of domain + names to 253 characters per :rfc:`1034`. Backwards incompatible changes in 1.10 ====================================== diff --git a/tests/validators/invalid_urls.txt b/tests/validators/invalid_urls.txt index 12a1226359..f7dc1e238a 100644 --- a/tests/validators/invalid_urls.txt +++ b/tests/validators/invalid_urls.txt @@ -50,3 +50,7 @@ http://[::1:2::3]:8080/ http://[] http://[]:8080 http://example..com/ +http://aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.example.com +http://example.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.com +http://example.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +http://aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaa diff --git a/tests/validators/valid_urls.txt b/tests/validators/valid_urls.txt index ad30811177..0dc4d61bea 100644 --- a/tests/validators/valid_urls.txt +++ b/tests/validators/valid_urls.txt @@ -63,3 +63,7 @@ http://0.0.0.0/ http://255.255.255.255 http://224.0.0.0 http://224.1.1.1 +http://aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.example.com +http://example.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.com +http://example.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +http://aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaa