Author: mark
Date: 2008-05-20 06:47:03 -0600 (Tue, 20 May 2008)
New Revision: 3437

Modified:
   FormEncode/trunk/formencode/validators.py
Log:
in Email validator, update of regex for domain names

Modified: FormEncode/trunk/formencode/validators.py
===================================================================
--- FormEncode/trunk/formencode/validators.py   2008-05-20 12:02:07 UTC (rev 
3436)
+++ FormEncode/trunk/formencode/validators.py   2008-05-20 12:47:03 UTC (rev 
3437)
@@ -1257,6 +1257,20 @@
         Traceback (most recent call last):
             ...
         Invalid: The domain portion of the email address is invalid (the 
portion after the @: foobar.com.5)
+        >>> e.to_python('[EMAIL PROTECTED]')
+        Traceback (most recent call last):
+            ...
+        Invalid: The domain portion of the email address is invalid (the 
portion after the @: foo..bar.com)
+        >>> e.to_python('[EMAIL PROTECTED]')
+        Traceback (most recent call last):
+            ...
+        Invalid: The domain portion of the email address is invalid (the 
portion after the @: .foo.bar.com)
+        >>> e.to_python('[EMAIL PROTECTED]')
+        Traceback (most recent call last):
+            ...
+        Invalid: The domain portion of the email address is invalid (the 
portion after the @: foo-.bar.com)
+        >>> e.to_python('[EMAIL PROTECTED]')
+        '[EMAIL PROTECTED]'
         >>> e.to_python('[EMAIL PROTECTED]')
         '[EMAIL PROTECTED]'
         >>> e = Email(resolve_domain=True)
@@ -1279,7 +1293,7 @@
     resolve_domain = False
 
     usernameRE = re.compile(r"^[^ \t\n\r@<>()]+$", re.I)
-    domainRE = re.compile(r"^[a-z0-9][a-z0-9\.\-_]*\.[a-z]+$", re.I)
+    domainRE = 
re.compile(r"^((?![.-])[a-z0-9_\-]{1,63}(?<!-)\.?)+((?<!\.)\.[a-z]{2,})$", re.I)
 
     messages = {
         'empty': _('Please enter an email address'),


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft 
Defy all challenges. Microsoft(R) Visual Studio 2008. 
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
FormEncode-CVS mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/formencode-cvs

Reply via email to