diff --git a/django/core/validators.py b/django/core/validators.py
index b1b82db..dad0a79 100644
|
a
|
b
|
class RegexValidator(object):
|
| 41 | 41 | class URLValidator(RegexValidator): |
| 42 | 42 | regex = re.compile( |
| 43 | 43 | r'^https?://' # http:// or https:// |
| 44 | | r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+[A-Z]{2,6}\.?|' #domain... |
| | 44 | r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' #domain... |
| 45 | 45 | r'localhost|' #localhost... |
| 46 | 46 | r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip |
| 47 | 47 | r'(?::\d+)?' # optional port |
diff --git a/tests/regressiontests/forms/tests/fields.py b/tests/regressiontests/forms/tests/fields.py
index 576a9c3..684e371 100644
|
a
|
b
|
class FieldsTests(TestCase):
|
| 570 | 570 | f.clean('http://google.com/we-love-microsoft.html') # good domain, bad page |
| 571 | 571 | except ValidationError, e: |
| 572 | 572 | self.assertEqual("[u'This URL appears to be a broken link.']", str(e)) |
| 573 | | # Valid and existent IDN |
| 574 | | self.assertEqual(u'http://\u05e2\u05d1\u05e8\u05d9\u05ea.idn.icann.org/', f.clean(u'http://עברית.idn.icann.org/')) |
| 575 | | # Valid but non-existent IDN |
| 576 | | try: |
| 577 | | f.clean(u'http://broken.עברית.idn.icann.org/') |
| 578 | | except ValidationError, e: |
| 579 | | self.assertEqual("[u'This URL appears to be a broken link.']", str(e)) |
| 580 | 573 | |
| 581 | 574 | def test_urlfield_4(self): |
| 582 | 575 | f = URLField(verify_exists=True, required=False) |
| … |
… |
class FieldsTests(TestCase):
|
| 600 | 593 | self.assertEqual(u'http://example.com/', f.clean('http://example.com')) |
| 601 | 594 | self.assertEqual(u'http://example.com/test', f.clean('http://example.com/test')) |
| 602 | 595 | |
| 603 | | def test_urlfield_ticket11826(self): |
| | 596 | def test_urlfield_8(self): |
| | 597 | # ticket #11826 |
| 604 | 598 | f = URLField() |
| 605 | 599 | self.assertEqual(u'http://example.com/?some_param=some_value', f.clean('http://example.com?some_param=some_value')) |
| 606 | 600 | |
| | 601 | def test_urlfield_9(self): |
| | 602 | f = URLField(verify_exists=False) |
| | 603 | urls = ( |
| | 604 | u'http://עברית.idn.icann.org/', |
| | 605 | u'http://sãopaulo.com/', |
| | 606 | u'http://sãopaulo.com.br/', |
| | 607 | u'http://пример.испытание/', |
| | 608 | u'http://مثال.إختبار/', |
| | 609 | u'http://例子.测试/', |
| | 610 | u'http://例子.測試/', |
| | 611 | u'http://उदाहरण.परीक्षा/', |
| | 612 | u'http://例え.テスト/', |
| | 613 | u'http://مثال.آزمایشی/', |
| | 614 | u'http://실례.테스트/', |
| | 615 | u'http://العربية.idn.icann.org/', |
| | 616 | ) |
| | 617 | for url in urls: |
| | 618 | # Valid and existent IDN |
| | 619 | self.assertEqual(url, f.clean(url)) |
| | 620 | # Valid but non-existent IDN |
| | 621 | try: |
| | 622 | f.clean(u'http://broken.עברית.idn.icann.org/') |
| | 623 | except ValidationError, e: |
| | 624 | self.assertEqual("[u'This URL appears to be a broken link.']", str(e)) |
| | 625 | |
| 607 | 626 | # BooleanField ################################################################ |
| 608 | 627 | |
| 609 | 628 | def test_booleanfield_1(self): |