Loading django/core/validators.py +8 −1 Original line number Diff line number Diff line Loading @@ -74,7 +74,14 @@ 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-]+(?<!-))*' tld_re = r'\.(?:[a-z' + ul + r']{2,}|xn--[a-z0-9]+)\.?' tld_re = ( '\.' # dot '(?!-)' # can't start with a dash '(?:[a-z' + ul + '-]{2,}' # domain label '|xn--[a-z0-9]+)' # or punycode label '(?<!-)' # can't end with a dash '\.?' # may have a trailing dot ) host_re = '(' + hostname_re + domain_re + tld_re + '|localhost)' regex = re.compile( Loading docs/releases/1.8.10.txt +3 −0 Original line number Diff line number Diff line Loading @@ -21,3 +21,6 @@ Bugfixes * Fixed :class:`~django.contrib.postgres.fields.RangeField` and :class:`~django.contrib.postgres.fields.ArrayField` serialization with ``None`` values (:ticket:`26215`). * Reallowed dashes in top-level domain names of URLs checked by ``URLValidator`` to fix a regression in Django 1.8 (:ticket:`26204`). tests/validators/invalid_urls.txt +3 −1 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ http://.com http://invalid-.com http://-invalid.com http://invalid.com- http://invalid.c-m http://invalid.-com http://inv-.alid-.com http://inv-.-alid.com file://localhost/path Loading @@ -33,6 +33,8 @@ http:// shouldfail.com :// should fail http://foo.bar/foo(bar)baz quux http://-error-.invalid/ http://dashinpunytld.trailingdot.xn--. http://dashinpunytld.xn--- http://-a.b.co http://a.b-.co http://a.-b.co Loading tests/validators/valid_urls.txt +4 −0 Original line number Diff line number Diff line Loading @@ -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://dashintld.c-m http://multipledashintld.a-b-c http://evenmoredashintld.a---c http://dashinpunytld.xn---c Loading
django/core/validators.py +8 −1 Original line number Diff line number Diff line Loading @@ -74,7 +74,14 @@ 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-]+(?<!-))*' tld_re = r'\.(?:[a-z' + ul + r']{2,}|xn--[a-z0-9]+)\.?' tld_re = ( '\.' # dot '(?!-)' # can't start with a dash '(?:[a-z' + ul + '-]{2,}' # domain label '|xn--[a-z0-9]+)' # or punycode label '(?<!-)' # can't end with a dash '\.?' # may have a trailing dot ) host_re = '(' + hostname_re + domain_re + tld_re + '|localhost)' regex = re.compile( Loading
docs/releases/1.8.10.txt +3 −0 Original line number Diff line number Diff line Loading @@ -21,3 +21,6 @@ Bugfixes * Fixed :class:`~django.contrib.postgres.fields.RangeField` and :class:`~django.contrib.postgres.fields.ArrayField` serialization with ``None`` values (:ticket:`26215`). * Reallowed dashes in top-level domain names of URLs checked by ``URLValidator`` to fix a regression in Django 1.8 (:ticket:`26204`).
tests/validators/invalid_urls.txt +3 −1 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ http://.com http://invalid-.com http://-invalid.com http://invalid.com- http://invalid.c-m http://invalid.-com http://inv-.alid-.com http://inv-.-alid.com file://localhost/path Loading @@ -33,6 +33,8 @@ http:// shouldfail.com :// should fail http://foo.bar/foo(bar)baz quux http://-error-.invalid/ http://dashinpunytld.trailingdot.xn--. http://dashinpunytld.xn--- http://-a.b.co http://a.b-.co http://a.-b.co Loading
tests/validators/valid_urls.txt +4 −0 Original line number Diff line number Diff line Loading @@ -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://dashintld.c-m http://multipledashintld.a-b-c http://evenmoredashintld.a---c http://dashinpunytld.xn---c