Skip to content

Commit

Permalink
Fixed #17100 -- Typo in the regex for EmailValidator. Thanks reames A…
Browse files Browse the repository at this point in the history
…T asymmetricventures com for the report and Claude Paroz for the patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17349 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
aaugustin committed Jan 7, 2012
1 parent f21a9da commit aa5d307
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion django/core/validators.py
Expand Up @@ -158,7 +158,8 @@ def __call__(self, value):


email_re = re.compile( email_re = re.compile(
r"(^[-!#$%&'*+/=?^_`{}|~0-9A-Z]+(\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+)*" # dot-atom r"(^[-!#$%&'*+/=?^_`{}|~0-9A-Z]+(\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+)*" # dot-atom
r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-011\013\014\016-\177])*"' # quoted-string # quoted-string, see also http://tools.ietf.org/html/rfc2822#section-3.2.5
r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-\011\013\014\016-\177])*"'
r')@((?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+[A-Z]{2,6}\.?$)' # domain r')@((?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+[A-Z]{2,6}\.?$)' # domain
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) 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)
validate_email = EmailValidator(email_re, _(u'Enter a valid e-mail address.'), 'invalid') validate_email = EmailValidator(email_re, _(u'Enter a valid e-mail address.'), 'invalid')
Expand Down
3 changes: 3 additions & 0 deletions tests/modeltests/validators/tests.py
Expand Up @@ -30,6 +30,9 @@
(validate_email, 'a @x.cz', ValidationError), (validate_email, 'a @x.cz', ValidationError),
(validate_email, 'something@@somewhere.com', ValidationError), (validate_email, 'something@@somewhere.com', ValidationError),
(validate_email, 'email@127.0.0.1', ValidationError), (validate_email, 'email@127.0.0.1', ValidationError),
# Quoted-string format (CR not allowed)
(validate_email, '"\\\011"@here.com', None),
(validate_email, '"\\\012"@here.com', ValidationError),


(validate_slug, 'slug-ok', None), (validate_slug, 'slug-ok', None),
(validate_slug, 'longer-slug-still-ok', None), (validate_slug, 'longer-slug-still-ok', None),
Expand Down

0 comments on commit aa5d307

Please sign in to comment.