-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Several fixes for parsing display names
* Fix error message text for input addresses without @-signs. The incorrect message was "There must be something after the @-sign.". This was broken by the changes to parse display names. Prior to that, the message was "The email address is not valid. It must have exactly one @-sign.". * Move the allow_display_name check to the end of the syntax checks. The optional checks should be the last to occur so that fatal syntax errors are raised first. * Check that display name email addresses have a closing angle bracket and nothing after. * Don't treat < + U+0338 (Combining Long Solidus Overlay) as the start of a bracketed email address. This would already be rejected because the combining character would be reported as an unsafe character at the start of the address, but it may be confusing since the caller won't see the address that way. When splitting the address into parts, skip the other special characters (@, quote, backslash) that have meaningful combining characters after them (i.e. they change under NFC normalization), although I don't think there are any such cases.
- Loading branch information
Showing
3 changed files
with
34 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -352,6 +352,7 @@ def test_domain_literal() -> None: | |
@pytest.mark.parametrize( | ||
'email_input,error_msg', | ||
[ | ||
('hello.world', 'An email address must have an @-sign.'), | ||
('my@localhost', 'The part after the @-sign is not valid. It should have a period.'), | ||
('[email protected]', 'An email address cannot have a period immediately after the @-sign.'), | ||
('my@.leadingfwdot.com', 'An email address cannot have a period immediately after the @-sign.'), | ||
|
@@ -413,6 +414,10 @@ def test_domain_literal() -> None: | |
('me@[untaggedtext]', 'The part after the @-sign in brackets is not an IPv4 address and has no address literal tag.'), | ||
('me@[tag:invalid space]', 'The part after the @-sign contains invalid characters in brackets: SPACE.'), | ||
('<[email protected]>', 'A display name and angle brackets around the email address are not permitted here.'), | ||
('<[email protected]', 'An open angle bracket at the start of the email address has to be followed by a close angle bracket at the end.'), | ||
('<[email protected]> !', 'There can\'t be anything after the email address.'), | ||
('<\u0338[email protected]', 'The email address contains invalid characters before the @-sign: \'<\'.'), | ||
('DisplayName <[email protected]>', 'An email address cannot have a hyphen immediately after the @-sign.'), | ||
('DisplayName <[email protected]>', 'A display name and angle brackets around the email address are not permitted here.'), | ||
('Display Name <[email protected]>', 'A display name and angle brackets around the email address are not permitted here.'), | ||
('\"Display Name\" <[email protected]>', 'A display name and angle brackets around the email address are not permitted here.'), | ||
|