Ticket #9948: urlfield-r9692.diff
File urlfield-r9692.diff, 1.7 KB (added by , 16 years ago) |
---|
-
django/forms/fields.py
527 527 528 528 url_re = re.compile( 529 529 r'^https?://' # http:// or https:// 530 r'(?:(?:[A-Z0-9 -]+\.)+[A-Z]{2,6}|' #domain...530 r'(?:(?:[A-Z0-9]+(?:-[A-Z0-9]+)*\.)+[A-Z]{2,6}|' #domain... 531 531 r'localhost|' #localhost... 532 532 r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip 533 533 r'(?::\d+)?' # optional port -
tests/regressiontests/forms/fields.py
864 864 u'http://www.example.com/' 865 865 >>> f.clean('http://www.example.com:8000/test') 866 866 u'http://www.example.com:8000/test' 867 >>> f.clean('valid-with-hyphens.com') 868 u'http://valid-with-hyphens.com/' 869 >>> f.clean('subdomain.domain.com') 870 u'http://subdomain.domain.com/' 867 871 >>> f.clean('http://200.8.9.10') 868 872 u'http://200.8.9.10/' 869 873 >>> f.clean('http://200.8.9.10:8000/test') … … 888 892 Traceback (most recent call last): 889 893 ... 890 894 ValidationError: [u'Enter a valid URL.'] 895 >>> f.clean('http://invalid-.com') 896 Traceback (most recent call last): 897 ... 898 ValidationError: [u'Enter a valid URL.'] 899 >>> f.clean('inv-.alid-.com') 900 Traceback (most recent call last): 901 ... 902 ValidationError: [u'Enter a valid URL.'] 903 >>> f.clean('inv-.-alid.com') 904 Traceback (most recent call last): 905 ... 906 ValidationError: [u'Enter a valid URL.'] 907 >>> f.clean('inv-----alid.com') 908 Traceback (most recent call last): 909 ... 910 ValidationError: [u'Enter a valid URL.'] 911 891 912 892 913 >>> f = URLField(required=False) 893 914 >>> f.clean('')