]> khamidou — GitHub mirrors - flanker.git/commitdiff
Allow hotmail addresses to begin with a number
authorLance McNearney <lance@mcnearney.net>
Thu, 19 Feb 2015 15:24:22 +0000 (07:24 -0800)
committerLance McNearney <lance@mcnearney.net>
Thu, 19 Feb 2015 15:24:22 +0000 (07:24 -0800)
flanker/addresslib/plugins/hotmail.py
tests/addresslib/plugins/hotmail_test.py

index 4b9c461befee95a0b8940c63f4cfc276d1294d5d..af4c1dc589714c4cdfe620fcf984638da74196e5 100644 (file)
@@ -6,7 +6,7 @@
     Notes:
 
         1-64 characters
-        must start with letter
+        must start with letter or number
         must end with letter, number, hyphen (-), or underscore (_)
         must use letters, numbers, periods (.), hypens (-), or underscores (_)
         only one plus (+) is allowed
@@ -16,7 +16,7 @@
 
         local-part      ->  main-part [ tags ]
         main-part       ->  hotmail-prefix hotmail-root hotmail-suffix
-        hotmail-prefix  ->  alpha
+        hotmail-prefix  ->  alpha | number
         hotmail-root    ->  alpha | number | period | hyphen | underscore
         hotmail-suffix  ->  alpha | number | hyphen | underscore
         tags            ->  + [ hotmail-root ]
@@ -33,7 +33,7 @@ import re
 from flanker.addresslib.tokenizer import TokenStream
 
 HOTMAIL_PREFIX  = re.compile(r'''
-                            [A-Za-z]+
+                            [A-Za-z0-9]+
                             ''', re.MULTILINE | re.VERBOSE)
 
 HOTMAIL_BASE    = re.compile(r'''
@@ -67,7 +67,7 @@ def validate(localpart):
     if l < 1 or l > 64:
         return False
 
-    # start can only be alpha
+    # start can only be alphanumeric
     if HOTMAIL_PREFIX.match(real_localpart[0]) is None:
         return False
 
index 0fe14e2a85b9b0c5b2578cff7b4bb39f12e38900..09d7accc116914652b509053ed151dfe38959e9c 100644 (file)
@@ -46,8 +46,8 @@ def test_hotmail_pass():
             addr = address.validate_address(localpart + DOMAIN)
             assert_not_equal(addr, None)
 
-        # start must be letter
-        for i in string.ascii_letters:
+        # start must be letter or number
+        for i in string.ascii_letters + string.digits:
             localpart = str(i) + 'a'
             addr = address.validate_address(localpart + DOMAIN)
             assert_not_equal(addr, None)
@@ -87,7 +87,7 @@ def test_hotmail_fail():
             assert_equal(addr, None)
 
         # invalid start char (must start with letter)
-        for i in string.punctuation + string.digits:
+        for i in string.punctuation:
             localpart = str(i) + 'a'
             addr = address.validate_address(localpart + DOMAIN)
             assert_equal(addr, None)