mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-40889: Fix email.utils.parseaddr
to handle routes with multiple intermediate hops
This commit is contained in:
parent
be257c5815
commit
bc29cb942f
3 changed files with 10 additions and 0 deletions
|
@ -349,6 +349,8 @@ class AddrlistClass:
|
|||
elif self.field[self.pos] == '@':
|
||||
self.pos += 1
|
||||
expectroute = True
|
||||
elif self.field[self.pos] == ',':
|
||||
self.pos += 1
|
||||
elif self.field[self.pos] == ':':
|
||||
self.pos += 1
|
||||
else:
|
||||
|
|
|
@ -3289,6 +3289,12 @@ class TestMiscellaneous(TestEmailBase):
|
|||
self.assertEqual(('', 'merwok.wok.wok@xample.com'),
|
||||
utils.parseaddr('merwok. wok . wok@xample.com'))
|
||||
|
||||
def test_parseaddr_handles_obsolete_addressing(self):
|
||||
self.assertEqual(('foobar', 'foo@bar.com'),
|
||||
utils.parseaddr('"foobar" <@hop.org:foo@bar.com>'))
|
||||
self.assertEqual(('foobar', 'foo@bar.com'),
|
||||
utils.parseaddr('"foobar" <@hop1.org,@hop2.org:foo@bar.com>'))
|
||||
|
||||
def test_formataddr_does_not_quote_parens_in_quoted_string(self):
|
||||
addr = ("'foo@example.com' (foo@example.com)",
|
||||
'foo@example.com')
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
Fix :func:`email.utils.parseaddr` to handle routes with multiple intermediate hops
|
||||
(see :rfc:`RFC 2822, §4.4 <2822#section-4.4>`). Patch by Ioana Tagirta.
|
Loading…
Add table
Add a link
Reference in a new issue