[Python-checkins] r45831 - in python/branches/release23-maint/Lib: email/_parseaddr.py email/test/test_email.py rfc822.py test/test_rfc822.py
barry.warsaw
python-checkins at python.org
Mon May 1 05:21:31 CEST 2006
Author: barry.warsaw
Date: Mon May 1 05:21:25 2006
New Revision: 45831
Modified:
python/branches/release23-maint/Lib/email/_parseaddr.py
python/branches/release23-maint/Lib/email/test/test_email.py
python/branches/release23-maint/Lib/rfc822.py
python/branches/release23-maint/Lib/test/test_rfc822.py
Log:
Back port from 2.4 branch:
Patch #1464708 from William McVey: fixed handling of nested comments in mail
addresses. E.g.
"Foo ((Foo Bar)) <foo at example.com>"
Fixes for both rfc822.py and email package.
Modified: python/branches/release23-maint/Lib/email/_parseaddr.py
==============================================================================
--- python/branches/release23-maint/Lib/email/_parseaddr.py (original)
+++ python/branches/release23-maint/Lib/email/_parseaddr.py Mon May 1 05:21:25 2006
@@ -365,6 +365,7 @@
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:
Modified: python/branches/release23-maint/Lib/email/test/test_email.py
==============================================================================
--- python/branches/release23-maint/Lib/email/test/test_email.py (original)
+++ python/branches/release23-maint/Lib/email/test/test_email.py Mon May 1 05:21:25 2006
@@ -2064,6 +2064,12 @@
['foo: ;', '"Jason R. Mastaler" <jason at dom.ain>']),
[('', ''), ('Jason R. Mastaler', 'jason at 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 at bar.com>'])
+ eq(addrs[0][1], 'foo at bar.com')
+
def test_utils_quote_unquote(self):
eq = self.assertEqual
msg = Message()
Modified: python/branches/release23-maint/Lib/rfc822.py
==============================================================================
--- python/branches/release23-maint/Lib/rfc822.py (original)
+++ python/branches/release23-maint/Lib/rfc822.py Mon May 1 05:21:25 2006
@@ -712,6 +712,7 @@
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 = 1
else:
Modified: python/branches/release23-maint/Lib/test/test_rfc822.py
==============================================================================
--- python/branches/release23-maint/Lib/test/test_rfc822.py (original)
+++ python/branches/release23-maint/Lib/test/test_rfc822.py Mon May 1 05:21:25 2006
@@ -45,6 +45,10 @@
print 'extra parsed address:', repr(n), repr(a)
continue
i = i + 1
+ self.assertEqual(mn, n,
+ "Un-expected name: %s != %s" % (`mn`, `n`))
+ self.assertEqual(ma, a,
+ "Un-expected address: %s != %s" % (`ma`, `a`))
if mn == n and ma == a:
pass
else:
@@ -129,6 +133,12 @@
'To: person at dom.ain (User J. Person)\n\n',
[('User J. Person', 'person at dom.ain')])
+ def test_doublecomment(self):
+ # The RFC allows comments within comments in an email addr
+ self.check(
+ 'To: person at dom.ain ((User J. Person)), John Doe <foo at bar.com>\n\n',
+ [('User J. Person', 'person at dom.ain'), ('John Doe', 'foo at bar.com')])
+
def test_twisted(self):
# This one is just twisted. I don't know what the proper
# result should be, but it shouldn't be to infloop, which is
More information about the Python-checkins
mailing list