Permalink
Browse files

[1.3.X] Fixed #17100 -- Typo in the regex for EmailValidator. Backpor…

…t of r17349 from trunk.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.3.X@17350 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent a9789c0 commit 9e124926167e2565ab64976bd20e131aca330ebd @aaugustin aaugustin committed Jan 7, 2012
Showing with 5 additions and 1 deletion.
  1. +2 −1 django/core/validators.py
  2. +3 −0 tests/modeltests/validators/tests.py
View
3 django/core/validators.py
@@ -147,7 +147,8 @@ def __call__(self, value):
email_re = re.compile(
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}\.?$', re.IGNORECASE) # domain
validate_email = EmailValidator(email_re, _(u'Enter a valid e-mail address.'), 'invalid')
View
3 tests/modeltests/validators/tests.py
@@ -28,6 +28,9 @@
(validate_email, 'abc', ValidationError),
(validate_email, 'a @x.cz', ValidationError),
(validate_email, 'something@@somewhere.com', 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, 'longer-slug-still-ok', None),

0 comments on commit 9e12492

Please sign in to comment.