summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Sveshnikov <alexey.sveshnikov@gmail.com>2015-07-03 19:35:55 +0300
committerTim Graham <timograham@gmail.com>2015-07-06 15:11:43 -0400
commit8c417564c7317a46883a779b765e54a28dbc7164 (patch)
treebdee1fea5ef38cf74ea774a1473780c5d58f5297
parent73cbf08159236c0529e02ed11b2a733c5102bfe2 (diff)
[1.8.x] Fixed #25059 -- Allowed Punycode TLDs in URLValidator
Backport of bc98bc56a52860688ea0ae2ec7b9e59ddb72a811 from master
-rw-r--r--django/core/validators.py2
-rw-r--r--docs/releases/1.8.3.txt3
-rw-r--r--docs/spelling_wordlist1
-rw-r--r--tests/validators/invalid_urls.txt1
-rw-r--r--tests/validators/valid_urls.txt1
5 files changed, 7 insertions, 1 deletions
diff --git a/django/core/validators.py b/django/core/validators.py
index bb8224f728..ac10d92956 100644
--- a/django/core/validators.py
+++ b/django/core/validators.py
@@ -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(
diff --git a/docs/releases/1.8.3.txt b/docs/releases/1.8.3.txt
index 600291d902..104d6eb725 100644
--- a/docs/releases/1.8.3.txt
+++ b/docs/releases/1.8.3.txt
@@ -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`).
diff --git a/docs/spelling_wordlist b/docs/spelling_wordlist
index 60c9726791..f8fb27a9d7 100644
--- a/docs/spelling_wordlist
+++ b/docs/spelling_wordlist
@@ -492,6 +492,7 @@ proxied
proxying
pseudocode
psycopg
+Punycode
Puthraya
py
pyformat
diff --git a/tests/validators/invalid_urls.txt b/tests/validators/invalid_urls.txt
index e225f256ba..9a4df36a20 100644
--- a/tests/validators/invalid_urls.txt
+++ b/tests/validators/invalid_urls.txt
@@ -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
diff --git a/tests/validators/valid_urls.txt b/tests/validators/valid_urls.txt
index 0d1dd779ea..040298f4fe 100644
--- a/tests/validators/valid_urls.txt
+++ b/tests/validators/valid_urls.txt
@@ -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