FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-40889: Fix `email.utils.parseaddr` to handle multiple hops by crazymerlyn · Pull Request #123311 · python/cpython · GitHub

Repository navigation

Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) .rst  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
2 changes: 2 additions & 0 deletions Lib/email/_parseaddr.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,8 @@ def getrouteaddr(self):
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:
Expand Down
6 changes: 6 additions & 0 deletions Lib/test/test_email/test_email.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -3289,6 +3289,12 @@ def test_parseaddr_preserves_spaces_in_local_part(self):
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')
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -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.

Back | FazBrowse Home | New Git URL