Skip to content

Commit 6d54215

Browse files
committed
gh-40889: Fix email.utils.parseaddr to handle routes with multiple intermediate hops
1 parent be257c5 commit 6d54215

3 files changed

Lines changed: 9 additions & 0 deletions

File tree

Lib/email/_parseaddr.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,8 @@ def getrouteaddr(self):
349349
elif self.field[self.pos] == '@':
350350
self.pos += 1
351351
expectroute = True
352+
elif self.field[self.pos] == ',':
353+
self.pos += 1
352354
elif self.field[self.pos] == ':':
353355
self.pos += 1
354356
else:

Lib/test/test_email/test_email.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3289,6 +3289,12 @@ def test_parseaddr_preserves_spaces_in_local_part(self):
32893289
self.assertEqual(('', '[email protected]'),
32903290
utils.parseaddr('merwok. wok . [email protected]'))
32913291

3292+
def test_parseaddr_handles_obsolete_addressing(self):
3293+
self.assertEqual(('foobar', '[email protected]'),
3294+
utils.parseaddr('"foobar" <@hop.org:[email protected]>'))
3295+
self.assertEqual(('foobar', '[email protected]'),
3296+
utils.parseaddr('"foobar" <@hop1.org,@hop2.org:[email protected]>'))
3297+
32923298
def test_formataddr_does_not_quote_parens_in_quoted_string(self):
32933299
32943300
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix :func:`email.utils.parseaddr` to handle routes with multiple intermediate hops.

0 commit comments

Comments
 (0)