Skip to content
Merged
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
2 changes: 1 addition & 1 deletion email_validator/syntax.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def unquote_quoted_string(text: str) -> tuple[str, bool]:
raise EmailSyntaxError("There can't be anything after the email address.")

# Remove the initial and trailing angle brackets.
addr_spec = right_part[1:].rstrip(">")
addr_spec = right_part[1:-1]

# Split the email address at the first unquoted @-sign.
local_part, domain_part = split_string_at_unquoted_special(addr_spec, ("@",))
Expand Down
14 changes: 14 additions & 0 deletions tests/test_syntax.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,20 @@ def test_email_invalid_syntax_strict(email_input: str, error_msg: str) -> None:
assert str(exc_info.value) == error_msg


@pytest.mark.parametrize(
'email_input',
[
'<[email protected]>>',
'Display Name <[email protected]>>',
'Display Name <[email protected]>>>',
])
def test_email_invalid_syntax_display_name(email_input: str) -> None:
# Only one close angle bracket may follow the address.
with pytest.raises(EmailSyntaxError) as exc_info:
validate_email(email_input, check_deliverability=False, allow_display_name=True)
assert str(exc_info.value) == "The part after the @-sign contains invalid characters: '>'."


@pytest.mark.parametrize(
'email_input',
[
Expand Down
Loading