Commit 898346ce authored by Barry Warsaw's avatar Barry Warsaw

Tokio Kikuchi's fix for SF bug #1629369; folding whitespace allowed in the

display name of an email address, e.g.

Foo
\tBar <foo@example.com>

Test case added by Barry.
parent cef2c74f
# Copyright (C) 2002-2006 Python Software Foundation # Copyright (C) 2002-2007 Python Software Foundation
# Contact: email-sig@python.org # Contact: email-sig@python.org
"""Email address parsing code. """Email address parsing code.
...@@ -172,6 +172,7 @@ class AddrlistClass: ...@@ -172,6 +172,7 @@ class AddrlistClass:
self.pos = 0 self.pos = 0
self.LWS = ' \t' self.LWS = ' \t'
self.CR = '\r\n' self.CR = '\r\n'
self.FWS = self.LWS + self.CR
self.atomends = self.specials + self.LWS + self.CR self.atomends = self.specials + self.LWS + self.CR
# Note that RFC 2822 now specifies `.' as obs-phrase, meaning that it # Note that RFC 2822 now specifies `.' as obs-phrase, meaning that it
# is obsolete syntax. RFC 2822 requires that we recognize obsolete # is obsolete syntax. RFC 2822 requires that we recognize obsolete
...@@ -418,7 +419,7 @@ class AddrlistClass: ...@@ -418,7 +419,7 @@ class AddrlistClass:
plist = [] plist = []
while self.pos < len(self.field): 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 self.pos += 1
elif self.field[self.pos] == '"': elif self.field[self.pos] == '"':
plist.append(self.getquote()) plist.append(self.getquote())
......
# Copyright (C) 2001-2006 Python Software Foundation # Copyright (C) 2001-2007 Python Software Foundation
# Contact: email-sig@python.org # Contact: email-sig@python.org
# email package unit tests # email package unit tests
...@@ -2165,6 +2165,12 @@ class TestMiscellaneous(TestEmailBase): ...@@ -2165,6 +2165,12 @@ class TestMiscellaneous(TestEmailBase):
# formataddr() quotes the name if there's a dot in it # formataddr() quotes the name if there's a dot in it
self.assertEqual(Utils.formataddr((a, b)), y) self.assertEqual(Utils.formataddr((a, b)), y)
def test_multiline_from_comment(self):
x = """\
Foo
\tBar <foo@example.com>"""
self.assertEqual(Utils.parseaddr(x), ('Foo Bar', 'foo@example.com'))
def test_quote_dump(self): def test_quote_dump(self):
self.assertEqual( self.assertEqual(
Utils.formataddr(('A Silly; Person', 'person@dom.ain')), Utils.formataddr(('A Silly; Person', 'person@dom.ain')),
......
# Copyright (C) 2001-2006 Python Software Foundation # Copyright (C) 2001-2007 Python Software Foundation
# Contact: email-sig@python.org # Contact: email-sig@python.org
# email package unit tests # email package unit tests
...@@ -2171,6 +2171,12 @@ class TestMiscellaneous(TestEmailBase): ...@@ -2171,6 +2171,12 @@ class TestMiscellaneous(TestEmailBase):
# formataddr() quotes the name if there's a dot in it # formataddr() quotes the name if there's a dot in it
self.assertEqual(utils.formataddr((a, b)), y) self.assertEqual(utils.formataddr((a, b)), y)
def test_multiline_from_comment(self):
x = """\
Foo
\tBar <foo@example.com>"""
self.assertEqual(utils.parseaddr(x), ('Foo Bar', 'foo@example.com'))
def test_quote_dump(self): def test_quote_dump(self):
self.assertEqual( self.assertEqual(
utils.formataddr(('A Silly; Person', 'person@dom.ain')), utils.formataddr(('A Silly; Person', 'person@dom.ain')),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment