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:08:43 -0400
commitbc98bc56a52860688ea0ae2ec7b9e59ddb72a811 (patch)
treee811bc575978eafc4f651e19970ba63409fc3be2
parentb74b94445de4173351b8c347deac22129c549f0f (diff)
Fixed #25059 -- Allowed Punycode TLDs in URLValidator
-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 3e4e744ff3..9feb33e8e9 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 ebc20f9b23..719fc3d31a 100644
--- a/docs/spelling_wordlist
+++ b/docs/spelling_wordlist
@@ -605,6 +605,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