Author: aaugustin
Date: 2012-01-07 10:48:12 -0800 (Sat, 07 Jan 2012)
New Revision: 17350

Modified:
   django/branches/releases/1.3.X/django/core/validators.py
   django/branches/releases/1.3.X/tests/modeltests/validators/tests.py
Log:
[1.3.X] Fixed #17100 -- Typo in the regex for EmailValidator. Backport of 
r17349 from trunk.


Modified: django/branches/releases/1.3.X/django/core/validators.py
===================================================================
--- django/branches/releases/1.3.X/django/core/validators.py    2012-01-07 
18:43:46 UTC (rev 17349)
+++ django/branches/releases/1.3.X/django/core/validators.py    2012-01-07 
18:48:12 UTC (rev 17350)
@@ -147,7 +147,8 @@
 
 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')
 

Modified: django/branches/releases/1.3.X/tests/modeltests/validators/tests.py
===================================================================
--- django/branches/releases/1.3.X/tests/modeltests/validators/tests.py 
2012-01-07 18:43:46 UTC (rev 17349)
+++ django/branches/releases/1.3.X/tests/modeltests/validators/tests.py 
2012-01-07 18:48:12 UTC (rev 17350)
@@ -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),

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to