Ticket #3421: url_re.2.patch

File url_re.2.patch, 1.1 KB (added by Chris Beaven, 17 years ago)
  • django/newforms/fields.py

     
    337337
    338338url_re = re.compile(
    339339    r'^https?://' # http:// or https://
    340     r'(?:[A-Z0-9-]+\.)+[A-Z]{2,6}' # domain
     340    r'(?:(?:[A-Z0-9-]+\.)+[A-Z]{2,6}|' #domain...
     341    r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip
    341342    r'(?::\d+)?' # optional port
    342343    r'(?:/?|/\S+)$', re.IGNORECASE)
    343344
  • tests/regressiontests/forms/tests.py

     
    15851585u'http://example.com'
    15861586>>> f.clean('http://www.example.com')
    15871587u'http://www.example.com'
     1588>>> f.clean('http://www.example.com:8000/test')
     1589u'http://www.example.com:8000/test'
     1590>>> f.clean('http://200.8.9.10')
     1591u'http://200.8.9.10'
     1592>>> f.clean('http://200.8.9.10:8000/test')
     1593u'http://200.8.9.10:8000/test'
    15881594>>> f.clean('foo')
    15891595Traceback (most recent call last):
    15901596...
Back to Top