Commit 8c417564 authored by Alexey Sveshnikov's avatar Alexey Sveshnikov Committed by Tim Graham
Browse files

[1.8.x] Fixed #25059 -- Allowed Punycode TLDs in URLValidator

Backport of bc98bc56 from master
parent 73cbf081
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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(
+3 −0
Original line number Diff line number Diff line
@@ -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`).
+1 −0
Original line number Diff line number Diff line
@@ -492,6 +492,7 @@ proxied
proxying
pseudocode
psycopg
Punycode
Puthraya
py
pyformat
+1 −0
Original line number Diff line number Diff line
@@ -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
+1 −0
Original line number Diff line number Diff line
@@ -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