From 82976e5c3f7abf20dfd4c3cc5aa586e57edef104 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Sat, 7 Nov 2015 11:08:16 +0100 Subject: Fixed #25637 -- Added URLValidator hostname length validation. URLValidator now validates the maximum length of a hostname and the maximum length of all labels inside the hostname. --- django/core/validators.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'django/core/validators.py') 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.'), -- cgit v1.3