[CMF-checkins] SVN: CMF/trunk/CMFDefault/ Even though the RFC does not allow it all-numeric domains do exist

Wichert Akkerman wichert at wiggy.net
Sun Aug 5 03:38:14 EDT 2007


Log message for revision 78593:
  Even though the RFC does not allow it all-numeric domains do exist

Changed:
  U   CMF/trunk/CMFDefault/tests/test_utils.py
  U   CMF/trunk/CMFDefault/utils.py

-=-
Modified: CMF/trunk/CMFDefault/tests/test_utils.py
===================================================================
--- CMF/trunk/CMFDefault/tests/test_utils.py	2007-08-05 07:35:06 UTC (rev 78592)
+++ CMF/trunk/CMFDefault/tests/test_utils.py	2007-08-05 07:38:14 UTC (rev 78593)
@@ -248,6 +248,8 @@
         from Products.CMFDefault.utils import checkEmailAddress
 
         self.assertEqual(checkEmailAddress('foo at example.com'), None)
+        self.assertEqual(checkEmailAddress('foo at 1bar.example.com'), None)
+        self.assertEqual(checkEmailAddress('foo at 123456.com'), None)
         self.assertEqual(checkEmailAddress('$.- at example.com'), None)
         self.assertEqual(checkEmailAddress(u'foo at example.com'), None)
         # CMF Collector issue #322
@@ -265,8 +267,6 @@
         self.assertRaises(EmailAddressInvalid, checkEmailAddress,
                           '.foo at example.com')
         self.assertRaises(EmailAddressInvalid, checkEmailAddress,
-                          'foo at 1bar.example.com')
-        self.assertRaises(EmailAddressInvalid, checkEmailAddress,
                           'foo at -bar.example.com')
         # RFC 2821 local-part: max 64 characters
         self.assertRaises(EmailAddressInvalid, checkEmailAddress,

Modified: CMF/trunk/CMFDefault/utils.py
===================================================================
--- CMF/trunk/CMFDefault/utils.py	2007-08-05 07:35:06 UTC (rev 78592)
+++ CMF/trunk/CMFDefault/utils.py	2007-08-05 07:38:14 UTC (rev 78593)
@@ -512,8 +512,9 @@
 # RFC 2821 local-part: max 64 characters
 # RFC 2821 domain: sequence of dot-separated labels
 # characters allowed in label: A-Za-z0-9-, first is a letter
-_DOMAIN_RE = re.compile(r'[^@]{1,64}@[A-Za-z][A-Za-z0-9-]*'
-                                r'(\.[A-Za-z][A-Za-z0-9-]*)+$')
+# Even though the RFC does not allow it all-numeric domains do exist
+_DOMAIN_RE = re.compile(r'[^@]{1,64}@[A-Za-z0-9][A-Za-z0-9-]+'
+                                r'(\.[A-Za-z0-9][A-Za-z0-9-]*)+$')
 
 security.declarePublic('checkEmailAddress')
 def checkEmailAddress(address):



More information about the CMF-checkins mailing list