|
From: <sub...@co...> - 2008-05-20 12:46:59
|
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('te...@fo...')
+ 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('test@.foo.bar.com')
+ 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('te...@fo...')
+ 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('no...@xn...')
+ 'no...@xn...'
>>> e.to_python('o*re...@te...')
'o*re...@te...'
>>> 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'),
|