From: Lance McNearney Date: Thu, 19 Feb 2015 15:24:22 +0000 (-0800) Subject: Allow hotmail addresses to begin with a number X-Git-Tag: v0.4.28~1^2 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=92f924c93f9ae5fb62c38eb1eeba4b5b5ce7fe4f;p=flanker.git Allow hotmail addresses to begin with a number --- diff --git a/flanker/addresslib/plugins/hotmail.py b/flanker/addresslib/plugins/hotmail.py index 4b9c461..af4c1dc 100644 --- a/flanker/addresslib/plugins/hotmail.py +++ b/flanker/addresslib/plugins/hotmail.py @@ -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 diff --git a/tests/addresslib/plugins/hotmail_test.py b/tests/addresslib/plugins/hotmail_test.py index 0fe14e2..09d7acc 100644 --- a/tests/addresslib/plugins/hotmail_test.py +++ b/tests/addresslib/plugins/hotmail_test.py @@ -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)