Skip to content

Commit 40cac07

Browse files
authored
Local part of the email address should be less or equal than 64 bytes. (#147)
1 parent bcd5147 commit 40cac07

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

tests/test_email.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def test_returns_true_on_valid_email(value, whitelist):
3434
('example@-invalid.com',),
3535
('example@inv-.alid-.com',),
3636
('example@inv-.-alid.com',),
37+
('john56789.john56789.john56789.john56789.john56789.john56789.john5@example.com',),
3738
# Quoted-string format (CR not allowed)
3839
('"\\\012"@here.com',),
3940
])

validators/email.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ def email(value, whitelist=None):
6161

6262
if not user_regex.match(user_part):
6363
return False
64+
65+
if len(user_part.encode("utf-8")) > 64:
66+
return False
6467

6568
if domain_part not in whitelist and not domain_regex.match(domain_part):
6669
# Try for possible IDN domain-part

0 commit comments

Comments
 (0)