[Python-checkins] r54280 - in python/trunk/Lib/email: _parseaddr.py test/test_email.py test/test_email_renamed.py
barry.warsaw
python-checkins at python.org
Mon Mar 12 04:20:07 CET 2007
Author: barry.warsaw
Date: Mon Mar 12 04:20:01 2007
New Revision: 54280
Modified:
python/trunk/Lib/email/_parseaddr.py
python/trunk/Lib/email/test/test_email.py
python/trunk/Lib/email/test/test_email_renamed.py
Log:
Tokio Kikuchi's fix for SF bug #1629369; folding whitespace allowed in the
display name of an email address, e.g.
Foo
\tBar <foo at example.com>
Test case added by Barry.
Modified: python/trunk/Lib/email/_parseaddr.py
==============================================================================
--- python/trunk/Lib/email/_parseaddr.py (original)
+++ python/trunk/Lib/email/_parseaddr.py Mon Mar 12 04:20:01 2007
@@ -1,4 +1,4 @@
-# Copyright (C) 2002-2006 Python Software Foundation
+# Copyright (C) 2002-2007 Python Software Foundation
# Contact: email-sig at python.org
"""Email address parsing code.
@@ -172,6 +172,7 @@
self.pos = 0
self.LWS = ' \t'
self.CR = '\r\n'
+ self.FWS = self.LWS + self.CR
self.atomends = self.specials + self.LWS + self.CR
# Note that RFC 2822 now specifies `.' as obs-phrase, meaning that it
# is obsolete syntax. RFC 2822 requires that we recognize obsolete
@@ -418,7 +419,7 @@
plist = []
while self.pos < len(self.field):
- if self.field[self.pos] in self.LWS:
+ if self.field[self.pos] in self.FWS:
self.pos += 1
elif self.field[self.pos] == '"':
plist.append(self.getquote())
Modified: python/trunk/Lib/email/test/test_email.py
==============================================================================
--- python/trunk/Lib/email/test/test_email.py (original)
+++ python/trunk/Lib/email/test/test_email.py Mon Mar 12 04:20:01 2007
@@ -1,4 +1,4 @@
-# Copyright (C) 2001-2006 Python Software Foundation
+# Copyright (C) 2001-2007 Python Software Foundation
# Contact: email-sig at python.org
# email package unit tests
@@ -2165,6 +2165,12 @@
# formataddr() quotes the name if there's a dot in it
self.assertEqual(Utils.formataddr((a, b)), y)
+ def test_multiline_from_comment(self):
+ x = """\
+Foo
+\tBar <foo at example.com>"""
+ self.assertEqual(Utils.parseaddr(x), ('Foo Bar', 'foo at example.com'))
+
def test_quote_dump(self):
self.assertEqual(
Utils.formataddr(('A Silly; Person', 'person at dom.ain')),
Modified: python/trunk/Lib/email/test/test_email_renamed.py
==============================================================================
--- python/trunk/Lib/email/test/test_email_renamed.py (original)
+++ python/trunk/Lib/email/test/test_email_renamed.py Mon Mar 12 04:20:01 2007
@@ -1,4 +1,4 @@
-# Copyright (C) 2001-2006 Python Software Foundation
+# Copyright (C) 2001-2007 Python Software Foundation
# Contact: email-sig at python.org
# email package unit tests
@@ -2171,6 +2171,12 @@
# formataddr() quotes the name if there's a dot in it
self.assertEqual(utils.formataddr((a, b)), y)
+ def test_multiline_from_comment(self):
+ x = """\
+Foo
+\tBar <foo at example.com>"""
+ self.assertEqual(utils.parseaddr(x), ('Foo Bar', 'foo at example.com'))
+
def test_quote_dump(self):
self.assertEqual(
utils.formataddr(('A Silly; Person', 'person at dom.ain')),
More information about the Python-checkins
mailing list