Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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 Lib/email/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
CRLF = '\r\n'
TICK = "'"

specialsre = re.compile(r'[][\\()<>@,:;".]')
specialsre = re.compile(r'[][\\()<>@,:;". ]')
escapesre = re.compile(r'[\\"]')

def _has_surrogates(s):
Expand Down
10 changes: 9 additions & 1 deletion Lib/test/test_email/test_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -3143,7 +3143,7 @@ def test_parseaddr_multiple_domains(self):
def test_noquote_dump(self):
self.assertEqual(
utils.formataddr(('A Silly Person', '[email protected]')),
'A Silly Person <[email protected]>')
'"A Silly Person" <[email protected]>')

def test_escape_dump(self):
self.assertEqual(
Expand All @@ -3164,6 +3164,14 @@ def test_escape_backslashes(self):
b = '[email protected]'
self.assertEqual(utils.parseaddr(utils.formataddr((a, b))), (a, b))

def test_parseaddr_formataddr_inverse(self):
# gh-91400
identity = '"foo bar" <[email protected]>'
single = utils.formataddr(utils.parseaddr(identity))
double = utils.formataddr(utils.parseaddr(single))
self.assertEqual(identity, single)
self.assertEqual(single, double)

def test_quotes_unicode_names(self):
# issue 1690608. email.utils.formataddr() should be rfc2047 aware.
name = "H\u00e4ns W\u00fcrst"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Make email.utils.formataddr and email.utils.parseaddr inverse of each other