Skip to content

Commit 49867ae

Browse files
author
Isaac Saldana
committed
Remove consecutive dot restriction since some addresses in Japan allow this
1 parent 9cd94cb commit 49867ae

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

README.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ Usage
1818
-----
1919
Please see the [test/test_parser.py](test/test_parser.py) for more test cases
2020

21-
from nibbler.parser import parse_email
21+
>>> from nibbler.parser import parse_email
2222

2323
# valid email
24-
parse_email('"much.more unusual"@example.com')
24+
>>> parse_email('"much.more unusual"@example.com')
25+
(True, '"much.more unusual"@example.com')
2526

2627
# invalid email
27-
parse_email('Abc.example.com')
28+
>>> parse_email('A@b@[email protected]')
29+
(False, 'A@b')
2830

2931

3032
Testing

nibbler/parser.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ def __init__(self):
88
self.previous_dot = False
99
self.previous_slash = False
1010
self.in_domain = False
11-
self.last_state = None
1211

1312
ATEXT = "!#$%&'*+-/=?^_`.{|}~@\"" + string.ascii_letters + string.digits
1413
SPECIAL = ['(', ')', ',', ':', ';', '<', '>', '[', '\\', ']', ' ']
@@ -52,9 +51,7 @@ def parse_email(email_str):
5251

5352
elif character == '.':
5453
# We can't have two consecutive dots
55-
if state.previous_dot:
56-
break
57-
elif not state.in_quotes:
54+
if not state.in_quotes:
5855
state.previous_dot = True
5956

6057
elif character == '@' and not state.in_quotes:

test/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ def setUp(self):
2020
'!#$%&\'*+-/=?^_`{}|[email protected]',
2121
'"()<>[]:,;@\\\\\\"!#$%&\'*+-/=?^_`{}| ~.a"@example.org',
2222
'" "@example.org',
23-
'abc."defghi"[email protected]'
23+
'abc."defghi"[email protected]',
24+
2425
]
2526

2627
# invalid email addresses:

0 commit comments

Comments
 (0)