mirror of
https://github.com/django/django.git
synced 2025-08-03 10:34:04 +00:00
Fixed #12988 -- Extended regular expression of the URLValidator to fully support IDN-URLs, especially the long TLDs.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15502 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
ff4a24af51
commit
47b1a8e704
2 changed files with 28 additions and 9 deletions
|
@ -571,13 +571,6 @@ class FieldsTests(TestCase):
|
|||
f.clean('http://google.com/we-love-microsoft.html') # good domain, bad page
|
||||
except ValidationError, e:
|
||||
self.assertEqual("[u'This URL appears to be a broken link.']", str(e))
|
||||
# Valid and existent IDN
|
||||
self.assertEqual(u'http://\u05e2\u05d1\u05e8\u05d9\u05ea.idn.icann.org/', f.clean(u'http://עברית.idn.icann.org/'))
|
||||
# Valid but non-existent IDN
|
||||
try:
|
||||
f.clean(u'http://broken.עברית.idn.icann.org/')
|
||||
except ValidationError, e:
|
||||
self.assertEqual("[u'This URL appears to be a broken link.']", str(e))
|
||||
|
||||
def test_urlfield_4(self):
|
||||
f = URLField(verify_exists=True, required=False)
|
||||
|
@ -601,10 +594,36 @@ class FieldsTests(TestCase):
|
|||
self.assertEqual(u'http://example.com/', f.clean('http://example.com'))
|
||||
self.assertEqual(u'http://example.com/test', f.clean('http://example.com/test'))
|
||||
|
||||
def test_urlfield_ticket11826(self):
|
||||
def test_urlfield_8(self):
|
||||
# ticket #11826
|
||||
f = URLField()
|
||||
self.assertEqual(u'http://example.com/?some_param=some_value', f.clean('http://example.com?some_param=some_value'))
|
||||
|
||||
def test_urlfield_9(self):
|
||||
f = URLField(verify_exists=False)
|
||||
urls = (
|
||||
u'http://עברית.idn.icann.org/',
|
||||
u'http://sãopaulo.com/',
|
||||
u'http://sãopaulo.com.br/',
|
||||
u'http://пример.испытание/',
|
||||
u'http://مثال.إختبار/',
|
||||
u'http://例子.测试/',
|
||||
u'http://例子.測試/',
|
||||
u'http://उदाहरण.परीक्षा/',
|
||||
u'http://例え.テスト/',
|
||||
u'http://مثال.آزمایشی/',
|
||||
u'http://실례.테스트/',
|
||||
u'http://العربية.idn.icann.org/',
|
||||
)
|
||||
for url in urls:
|
||||
# Valid and existent IDN
|
||||
self.assertEqual(url, f.clean(url))
|
||||
# Valid but non-existent IDN
|
||||
try:
|
||||
f.clean(u'http://broken.עברית.idn.icann.org/')
|
||||
except ValidationError, e:
|
||||
self.assertEqual("[u'This URL appears to be a broken link.']", str(e))
|
||||
|
||||
# BooleanField ################################################################
|
||||
|
||||
def test_booleanfield_1(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue