Ticket #12988: 12988.1.diff

File 12988.1.diff, 3.2 KB (added by Jannis Leidel, 13 years ago)
  • django/core/validators.py

    diff --git a/django/core/validators.py b/django/core/validators.py
    index b1b82db..dad0a79 100644
    a b class RegexValidator(object):  
    4141class URLValidator(RegexValidator):
    4242    regex = re.compile(
    4343        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...
    4545        r'localhost|' #localhost...
    4646        r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip
    4747        r'(?::\d+)?' # optional port
  • tests/regressiontests/forms/tests/fields.py

    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):  
    570570            f.clean('http://google.com/we-love-microsoft.html') # good domain, bad page
    571571        except ValidationError, e:
    572572            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))
    580573
    581574    def test_urlfield_4(self):
    582575        f = URLField(verify_exists=True, required=False)
    class FieldsTests(TestCase):  
    600593        self.assertEqual(u'http://example.com/', f.clean('http://example.com'))
    601594        self.assertEqual(u'http://example.com/test', f.clean('http://example.com/test'))
    602595
    603     def test_urlfield_ticket11826(self):
     596    def test_urlfield_8(self):
     597        # ticket #11826
    604598        f = URLField()
    605599        self.assertEqual(u'http://example.com/?some_param=some_value', f.clean('http://example.com?some_param=some_value'))
    606600
     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
    607626    # BooleanField ################################################################
    608627
    609628    def test_booleanfield_1(self):
Back to Top