diff options
| author | Dheerendra Rathor <dheeru.rathor14@gmail.com> | 2015-10-28 12:24:57 +0530 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-10-29 11:14:20 -0400 |
| commit | 6bb9f51ab8e3cc56b05238ea012763ba775ab896 (patch) | |
| tree | f6235205fede6a3cde5d0b8664e16deecd6c5e60 | |
| parent | 6fb9424ff034b45cee3f16eafda3e4629545ce4f (diff) | |
[1.9.x] Fixed #25620 -- Made URLValidator prohibit URLs with consecutive dots in the domain section.
Backport of 96fe90f5356971e0e51a0bc41e045dde600d7521 from master
| -rw-r--r-- | django/core/validators.py | 2 | ||||
| -rw-r--r-- | docs/releases/1.8.6.txt | 4 | ||||
| -rw-r--r-- | tests/validators/invalid_urls.txt | 1 |
3 files changed, 6 insertions, 1 deletions
diff --git a/django/core/validators.py b/django/core/validators.py index ee026f5e1d..69cc76ffab 100644 --- a/django/core/validators.py +++ b/django/core/validators.py @@ -84,7 +84,7 @@ class URLValidator(RegexValidator): # 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-]*(?<!-))*' + domain_re = r'(?:\.(?!-)[a-z' + ul + r'0-9-]+(?<!-))*' tld_re = r'\.(?:[a-z' + ul + r']{2,}|xn--[a-z0-9]+)\.?' host_re = '(' + hostname_re + domain_re + tld_re + '|localhost)' diff --git a/docs/releases/1.8.6.txt b/docs/releases/1.8.6.txt index 76eb32902d..3383e253d0 100644 --- a/docs/releases/1.8.6.txt +++ b/docs/releases/1.8.6.txt @@ -44,3 +44,7 @@ Bugfixes * Added a helpful error message when Django and South migrations exist in the 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`). diff --git a/tests/validators/invalid_urls.txt b/tests/validators/invalid_urls.txt index a3393d76ed..12a1226359 100644 --- a/tests/validators/invalid_urls.txt +++ b/tests/validators/invalid_urls.txt @@ -49,3 +49,4 @@ http://.www.foo.bar./ http://[::1:2::3]:8080/ http://[] http://[]:8080 +http://example..com/ |
