From cbbc3f19c157a1b464f0faa8a396777040e96c8e Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Mon, 12 Mar 2007 03:20:01 +0000 Subject: Tokio Kikuchi's fix for SF bug #1629369; folding whitespace allowed in the display name of an email address, e.g. Foo \tBar Test case added by Barry. --- Lib/email/_parseaddr.py | 5 +++-- Lib/email/test/test_email.py | 8 +++++++- Lib/email/test/test_email_renamed.py | 8 +++++++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Lib/email/_parseaddr.py b/Lib/email/_parseaddr.py index a08c43e..791d892 100644 --- a/Lib/email/_parseaddr.py +++ b/Lib/email/_parseaddr.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2006 Python Software Foundation +# Copyright (C) 2002-2007 Python Software Foundation # Contact: email-sig@python.org """Email address parsing code. @@ -172,6 +172,7 @@ class AddrlistClass: 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 @@ class AddrlistClass: 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()) diff --git a/Lib/email/test/test_email.py b/Lib/email/test/test_email.py index 13801dc..eb2a73c 100644 --- a/Lib/email/test/test_email.py +++ b/Lib/email/test/test_email.py @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2006 Python Software Foundation +# Copyright (C) 2001-2007 Python Software Foundation # Contact: email-sig@python.org # email package unit tests @@ -2165,6 +2165,12 @@ class TestMiscellaneous(TestEmailBase): # 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 """ + self.assertEqual(Utils.parseaddr(x), ('Foo Bar', 'foo@example.com')) + def test_quote_dump(self): self.assertEqual( Utils.formataddr(('A Silly; Person', 'person@dom.ain')), diff --git a/Lib/email/test/test_email_renamed.py b/Lib/email/test/test_email_renamed.py index 30f39b9..1995040 100644 --- a/Lib/email/test/test_email_renamed.py +++ b/Lib/email/test/test_email_renamed.py @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2006 Python Software Foundation +# Copyright (C) 2001-2007 Python Software Foundation # Contact: email-sig@python.org # email package unit tests @@ -2171,6 +2171,12 @@ class TestMiscellaneous(TestEmailBase): # 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 """ + self.assertEqual(utils.parseaddr(x), ('Foo Bar', 'foo@example.com')) + def test_quote_dump(self): self.assertEqual( utils.formataddr(('A Silly; Person', 'person@dom.ain')), -- cgit v0.12