diff options
author | Barry Warsaw <barry@python.org> | 2006-05-01 03:03:02 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2006-05-01 03:03:02 (GMT) |
commit | dbcc8d9b24496ca55dd349cd2eb5273cf6723343 (patch) | |
tree | 3db32de8b91c37685d38008263918773fcc41a39 /Lib/email | |
parent | 09612281efc664a7705014349791cbfbb7af15bc (diff) | |
download | cpython-dbcc8d9b24496ca55dd349cd2eb5273cf6723343.zip cpython-dbcc8d9b24496ca55dd349cd2eb5273cf6723343.tar.gz cpython-dbcc8d9b24496ca55dd349cd2eb5273cf6723343.tar.bz2 |
Port forward from 2.4 branch:
Patch #1464708 from William McVey: fixed handling of nested comments in mail
addresses. E.g.
"Foo ((Foo Bar)) <foo@example.com>"
Fixes for both rfc822.py and email package. This patch needs to be back
ported to Python 2.3 for email 2.5.
Diffstat (limited to 'Lib/email')
-rw-r--r-- | Lib/email/_parseaddr.py | 1 | ||||
-rw-r--r-- | Lib/email/test/test_email.py | 6 | ||||
-rw-r--r-- | Lib/email/test/test_email_renamed.py | 6 |
3 files changed, 13 insertions, 0 deletions
diff --git a/Lib/email/_parseaddr.py b/Lib/email/_parseaddr.py index 5821ddf..a08c43e 100644 --- a/Lib/email/_parseaddr.py +++ b/Lib/email/_parseaddr.py @@ -367,6 +367,7 @@ class AddrlistClass: break elif allowcomments and self.field[self.pos] == '(': slist.append(self.getcomment()) + continue # have already advanced pos from getcomment elif self.field[self.pos] == '\\': quote = True else: diff --git a/Lib/email/test/test_email.py b/Lib/email/test/test_email.py index d977693..a197a36 100644 --- a/Lib/email/test/test_email.py +++ b/Lib/email/test/test_email.py @@ -2215,6 +2215,12 @@ class TestMiscellaneous(TestEmailBase): ['foo: ;', '"Jason R. Mastaler" <jason@dom.ain>']), [('', ''), ('Jason R. Mastaler', 'jason@dom.ain')]) + def test_getaddresses_embedded_comment(self): + """Test proper handling of a nested comment""" + eq = self.assertEqual + addrs = Utils.getaddresses(['User ((nested comment)) <foo@bar.com>']) + eq(addrs[0][1], 'foo@bar.com') + def test_utils_quote_unquote(self): eq = self.assertEqual msg = Message() diff --git a/Lib/email/test/test_email_renamed.py b/Lib/email/test/test_email_renamed.py index 4ac2ee9..95d06cb 100644 --- a/Lib/email/test/test_email_renamed.py +++ b/Lib/email/test/test_email_renamed.py @@ -2221,6 +2221,12 @@ class TestMiscellaneous(TestEmailBase): ['foo: ;', '"Jason R. Mastaler" <jason@dom.ain>']), [('', ''), ('Jason R. Mastaler', 'jason@dom.ain')]) + def test_getaddresses_embedded_comment(self): + """Test proper handling of a nested comment""" + eq = self.assertEqual + addrs = utils.getaddresses(['User ((nested comment)) <foo@bar.com>']) + eq(addrs[0][1], 'foo@bar.com') + def test_utils_quote_unquote(self): eq = self.assertEqual msg = Message() |