Skip to content
Open
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
17 changes: 17 additions & 0 deletions Lib/test/test_email/test_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -3319,6 +3319,23 @@ def test_parsing_errors(self):
# Test email.utils.supports_strict_parsing attribute
self.assertEqual(email.utils.supports_strict_parsing, True)

def test_parseaddr_unicode(self):
# CVE-2023-27043 Unicode regression guard. The 2.7 refactor had to
# accept both str and unicode at the parseaddr() boundary; in Python 3
# str is already Unicode, so this test just pins that strict-mode
# parsing still accepts valid non-ASCII input and agrees with the
# non-strict path.
for addr in (
'user@example.com',
'Test User <user@example.com>',
'"Test User" <user@example.com>',
'"Sürname, Firstname" <to@example.com>',
):
with self.subTest(addr=addr):
strict = utils.parseaddr(addr, strict=True)
self.assertNotEqual(strict, ('', ''))
self.assertEqual(strict, utils.parseaddr(addr, strict=False))

def test_getaddresses_nasty(self):
for addresses, expected in (
(['"Sürname, Firstname" <to@example.com>'],
Expand Down