Fixed #25059 -- Allowed Punycode TLDs in URLValidator

This commit is contained in:
Alexey Sveshnikov 2015-07-03 19:35:55 +03:00 committed by Tim Graham
parent b74b94445d
commit bc98bc56a5
5 changed files with 7 additions and 1 deletions

View File

@ -74,7 +74,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]+(?:[a-z' + ul + r'0-9-]*[a-z' + ul + r'0-9]+)*)*'
tld_re = r'\.[a-z' + ul + r']{2,}\.?'
tld_re = r'\.(?:[a-z' + ul + r']{2,}|xn--[a-z0-9]+)\.?'
host_re = '(' + hostname_re + domain_re + tld_re + '|localhost)'
regex = re.compile(

View File

@ -92,3 +92,6 @@ Bugfixes
* Fixed a regression in the ``unordered_list`` template filter on certain
inputs (:ticket:`25031`).
* Fixed a regression in ``URLValidator`` that invalidated Punycode TLDs
(:ticket:`25059`).

View File

@ -605,6 +605,7 @@ proxied
proxying
pseudocode
psycopg
Punycode
Puthraya
py
pyformat

View File

@ -6,6 +6,7 @@ http://.com
http://invalid-.com
http://-invalid.com
http://invalid.com-
http://invalid.c-m
http://inv-.alid-.com
http://inv-.-alid.com
file://localhost/path

View File

@ -48,6 +48,7 @@ http://مثال.إختبار
http://例子.测试
http://उदाहरण.परीक्षा
http://-.~_!$&'()*+,;=:%40:80%2f::::::@example.com
http://xn--7sbb4ac0ad0be6cf.xn--p1ai
http://1337.net
http://a.b-c.de
http://223.255.255.254