summaryrefslogtreecommitdiff
path: root/tests/validators
diff options
context:
space:
mode:
authorDanilo Bargen <mail@dbrgn.ch>2014-11-03 18:01:31 +0100
committerTim Graham <timograham@gmail.com>2015-01-06 14:04:25 -0500
commit2e65d56156b622e2393dee1af66e9c799a51924f (patch)
tree78a9adb4f512e5c881fef51748d790d7c3be7200 /tests/validators
parent6288fccfda91593438f3b2f03998b7d7b6b0fcc0 (diff)
downloaddjango-2e65d56156b622e2393dee1af66e9c799a51924f.tar.gz
Fixed #20003 -- Improved and extended URLValidator
This adds support for authentication data (`user:password`) in URLs, IPv6 addresses, and unicode domains. The test suite has been improved by adding test URLs from http://mathiasbynens.be/demo/url-regex (with a few adjustments, like allowing local and reserved IPs). The previous URL validation regex failed this test suite on 13 occasions, the validator was updated based on https://gist.github.com/dperini/729294.
Diffstat (limited to 'tests/validators')
-rw-r--r--tests/validators/invalid_urls.txt36
-rw-r--r--tests/validators/valid_urls.txt47
2 files changed, 83 insertions, 0 deletions
diff --git a/tests/validators/invalid_urls.txt b/tests/validators/invalid_urls.txt
index 37c34776d0..e225f256ba 100644
--- a/tests/validators/invalid_urls.txt
+++ b/tests/validators/invalid_urls.txt
@@ -10,3 +10,39 @@ http://inv-.alid-.com
http://inv-.-alid.com
file://localhost/path
git://example.com/
+http://.
+http://..
+http://../
+http://?
+http://??
+http://??/
+http://#
+http://##
+http://##/
+http://foo.bar?q=Spaces should be encoded
+//
+//a
+///a
+///
+http:///a
+foo.com
+rdar://1234
+h://test
+http:// shouldfail.com
+:// should fail
+http://foo.bar/foo(bar)baz quux
+http://-error-.invalid/
+http://-a.b.co
+http://a.b-.co
+http:/
+http://
+http://
+http://1.1.1.1.1
+http://123.123.123
+http://3628126748
+http://123
+http://.www.foo.bar/
+http://.www.foo.bar./
+http://[::1:2::3]:8080/
+http://[]
+http://[]:8080
diff --git a/tests/validators/valid_urls.txt b/tests/validators/valid_urls.txt
index 9f1519c84f..0d1dd779ea 100644
--- a/tests/validators/valid_urls.txt
+++ b/tests/validators/valid_urls.txt
@@ -2,6 +2,7 @@ http://www.djangoproject.com/
HTTP://WWW.DJANGOPROJECT.COM/
http://localhost/
http://example.com/
+http://example.com./
http://www.example.com/
http://www.example.com:8000/test
http://valid-with-hyphens.com/
@@ -14,3 +15,49 @@ http://example.com/index.php?something=value&another=value2
https://example.com/
ftp://example.com/
ftps://example.com/
+http://foo.com/blah_blah
+http://foo.com/blah_blah/
+http://foo.com/blah_blah_(wikipedia)
+http://foo.com/blah_blah_(wikipedia)_(again)
+http://www.example.com/wpstyle/?p=364
+https://www.example.com/foo/?bar=baz&inga=42&quux
+http://✪df.ws/123
+http://userid:password@example.com:8080
+http://userid:password@example.com:8080/
+http://userid@example.com
+http://userid@example.com/
+http://userid@example.com:8080
+http://userid@example.com:8080/
+http://userid:password@example.com
+http://userid:password@example.com/
+http://142.42.1.1/
+http://142.42.1.1:8080/
+http://➡.ws/䨹
+http://⌘.ws
+http://⌘.ws/
+http://foo.com/blah_(wikipedia)#cite-1
+http://foo.com/blah_(wikipedia)_blah#cite-1
+http://foo.com/unicode_(✪)_in_parens
+http://foo.com/(something)?after=parens
+http://☺.damowmow.com/
+http://code.google.com/events/#&product=browser
+http://j.mp
+ftp://foo.bar/baz
+http://foo.bar/?q=Test%20URL-encoded%20stuff
+http://مثال.إختبار
+http://例子.测试
+http://उदाहरण.परीक्षा
+http://-.~_!$&'()*+,;=:%40:80%2f::::::@example.com
+http://1337.net
+http://a.b-c.de
+http://223.255.255.254
+ftps://foo.bar/
+http://10.1.1.254
+http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html
+http://[::192.9.5.5]/ipng
+http://[::ffff:192.9.5.5]/ipng
+http://[::1]:8080/
+http://0.0.0.0/
+http://255.255.255.255
+http://224.0.0.0
+http://224.1.1.1