diff --git a/src/validators/email.py b/src/validators/email.py index eff09bd..bc17d77 100644 --- a/src/validators/email.py +++ b/src/validators/email.py @@ -85,11 +85,15 @@ def email( ) if re.match( # extended latin - r"(^[\u0100-\u017F\u0180-\u024F]" + r"(^[\u0100-\u017F\u0180-\u024F\u00A0-\u00FF]" # dot-atom - + r"|[-!#$%&'*+/=?^_`{}|~0-9a-z]+(\.[-!#$%&'*+/=?^_`{}|~0-9a-z]+)*$" + + r"|[\u0100-\u017F\u0180-\u024F\u00A0-\u00FF0-9a-z!#$%&'*+/=?^_`{}|~\-]+" + + r"(\.[\u0100-\u017F\u0180-\u024F\u00A0-\u00FF0-9a-z!#$%&'*+/=?^_`{}|~\-]+)*$" # quoted-string - + r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\011.])*"$)', + + r'|^"(' + + r"[\u0100-\u017F\u0180-\u024F\u00A0-\u00FF\001-\010\013\014\016-\037" + + r"!#-\[\]-\177]|\\[\011.]" + + r')*")$', username_part, re.IGNORECASE, ) diff --git a/tests/test_email.py b/tests/test_email.py index 029c45e..56c95f3 100644 --- a/tests/test_email.py +++ b/tests/test_email.py @@ -48,6 +48,9 @@ def test_returns_true_on_valid_email(value: str): ('"test@test"@example.com',), # Quoted-string format (CR not allowed) ('"\\\012"@here.com',), + # Non-quoted space/semicolon not allowed + ("stephen smith@example.com",), + ("stephen;smith@example.com",), ], ) def test_returns_failed_validation_on_invalid_email(value: str):