Ticket #16166: ticket_16166_for_r16342.diff
File ticket_16166_for_r16342.diff, 1.6 KB (added by , 13 years ago) |
---|
-
django/core/validators.py
134 134 email_re = re.compile( 135 135 r"(^[-!#$%&'*+/=?^_`{}|~0-9A-Z]+(\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+)*" # dot-atom 136 136 r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-011\013\014\016-\177])*"' # quoted-string 137 r')@(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+[A-Z]{2,6}\.?$', re.IGNORECASE) # domain 137 r')@((?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+[A-Z]{2,6}\.?$)' # domain 138 r'|\[(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}\]$', re.IGNORECASE) # literal form, ipv4 address (SMTP 4.1.3) 138 139 validate_email = EmailValidator(email_re, _(u'Enter a valid e-mail address.'), 'invalid') 139 140 140 141 slug_re = re.compile(r'^[-\w]+$') -
tests/modeltests/validators/tests.py
22 22 23 23 (validate_email, 'email@here.com', None), 24 24 (validate_email, 'weirder-email@here.and.there.com', None), 25 (validate_email, 'email@[127.0.0.1]', None), 25 26 26 27 (validate_email, None, ValidationError), 27 28 (validate_email, '', ValidationError), 28 29 (validate_email, 'abc', ValidationError), 29 30 (validate_email, 'a @x.cz', ValidationError), 30 31 (validate_email, 'something@@somewhere.com', ValidationError), 32 (validate_email, 'email@127.0.0.1', ValidationError), 31 33 32 34 (validate_slug, 'slug-ok', None), 33 35 (validate_slug, 'longer-slug-still-ok', None),