[1.8.x] Fixed #25620 -- Made URLValidator prohibit URLs with consecutive dots in the domain section.

Backport of 96fe90f535 from master
This commit is contained in:
Dheerendra Rathor 2015-10-28 12:24:57 +05:30 committed by Tim Graham
parent 528ef71a76
commit 540de2f797
3 changed files with 6 additions and 1 deletions

View File

@ -73,7 +73,7 @@ class URLValidator(RegexValidator):
# Host patterns # Host patterns
hostname_re = r'[a-z' + ul + r'0-9](?:[a-z' + ul + r'0-9-]*[a-z' + ul + r'0-9])?' 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-]*(?<!-))*' domain_re = r'(?:\.(?!-)[a-z' + ul + r'0-9-]+(?<!-))*'
tld_re = r'\.(?:[a-z' + ul + r']{2,}|xn--[a-z0-9]+)\.?' tld_re = r'\.(?:[a-z' + ul + r']{2,}|xn--[a-z0-9]+)\.?'
host_re = '(' + hostname_re + domain_re + tld_re + '|localhost)' host_re = '(' + hostname_re + domain_re + tld_re + '|localhost)'

View File

@ -44,3 +44,7 @@ Bugfixes
* Added a helpful error message when Django and South migrations exist in the * Added a helpful error message when Django and South migrations exist in the
same directory (:ticket:`25618`). same directory (:ticket:`25618`).
* Fixed a regression in ``URLValidator`` that allowed URLs with consecutive
dots in the domain section (like ``http://example..com/``) to pass
(:ticket:`25620`).

View File

@ -49,3 +49,4 @@ http://.www.foo.bar./
http://[::1:2::3]:8080/ http://[::1:2::3]:8080/
http://[] http://[]
http://[]:8080 http://[]:8080
http://example..com/