Skip to content

Commit 4194c66

Browse files
committed
Fix email.utils.parseaddr to handle multiple hops
1 parent 55e53c3 commit 4194c66

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

Lib/email/_parseaddr.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,8 @@ def getrouteaddr(self):
338338
elif self.field[self.pos] == '@':
339339
self.pos += 1
340340
expectroute = True
341+
elif self.field[self.pos] == ',':
342+
self.pos += 1
341343
elif self.field[self.pos] == ':':
342344
self.pos += 1
343345
else:

Lib/test/test_email/test_email.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3141,6 +3141,12 @@ def test_parseaddr_preserves_spaces_in_local_part(self):
31413141
self.assertEqual(('', 'merwok.wok.wok@xample.com'),
31423142
utils.parseaddr('merwok. wok . wok@xample.com'))
31433143

3144+
def test_parseaddr_handles_obsolete_addressing(self):
3145+
self.assertEqual(('foobar', 'foo@bar.com'),
3146+
utils.parseaddr('"foobar" <@hop.org:foo@bar.com>'))
3147+
self.assertEqual(('foobar', 'foo@bar.com'),
3148+
utils.parseaddr('"foobar" <@hop1.org,@hop2.org:foo@bar.com>'))
3149+
31443150
def test_formataddr_does_not_quote_parens_in_quoted_string(self):
31453151
addr = ("'foo@example.com' (foo@example.com)",
31463152
'foo@example.com')

0 commit comments

Comments
 (0)