Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/validators/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ def email(
)
if re.fullmatch( # 2026-10-11: Validate the complete local part.
# extended latin
r"(^[\u0100-\u017F\u0180-\u024F\u00A0-\u00FF]"
r"(^[\u0100-\u017F\u0180-\u024F\u00A1-\u00FF]"
# dot-atom
+ r"|[\u0100-\u017F\u0180-\u024F\u00A0-\u00FF0-9a-z!#$%&'*+/=?^_`{}|~\-]+"
+ r"(\.[\u0100-\u017F\u0180-\u024F\u00A0-\u00FF0-9a-z!#$%&'*+/=?^_`{}|~\-]+)*$"
+ r"|[\u0100-\u017F\u0180-\u024F\u00A1-\u00FF0-9a-z!#$%&'*+/=?^_`{}|~\-]+"
+ r"(\.[\u0100-\u017F\u0180-\u024F\u00A1-\u00FF0-9a-z!#$%&'*+/=?^_`{}|~\-]+)*$"
# quoted-string
+ r'|^"('
+ r"[\u0100-\u017F\u0180-\u024F\u00A0-\u00FF\001-\010\013\014\016-\037"
+ r"[\u0100-\u017F\u0180-\u024F\u00A0-\u00FF\001-\010\013\014\016-\037\011\040"
+ r"!#-\[\]-\177]|\\[\011.]"
+ r')*")$',
username_part,
Expand Down
3 changes: 3 additions & 0 deletions tests/test_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
("łemłail@here.com",),
("email@localdomain.org",),
('"\\\011"@here.com',),
('"john doe"@example.com',),
],
)
def test_returns_true_on_valid_email(value: str):
Expand Down Expand Up @@ -51,6 +52,8 @@ def test_returns_true_on_valid_email(value: str):
# Non-quoted space/semicolon not allowed
("stephen smith@example.com",),
("stephen;smith@example.com",),
("\u00a0@example.com",),
("a\u00a0b@example.com",),
],
)
def test_returns_failed_validation_on_invalid_email(value: str):
Expand Down