summaryrefslogtreecommitdiffstats
path: root/Lib/email/test
diff options
context:
space:
mode:
authorR. David Murray <rdmurray@bitdance.com>2010-10-02 16:04:44 (GMT)
committerR. David Murray <rdmurray@bitdance.com>2010-10-02 16:04:44 (GMT)
commit7f8199a9979c9f100d754d4910d5e1bd6f929d9a (patch)
tree0800e3381257e6caf644f11312e6acc05e682039 /Lib/email/test
parent996e13c838a9926087532755ea43b7ecba1ddb50 (diff)
downloadcpython-7f8199a9979c9f100d754d4910d5e1bd6f929d9a.zip
cpython-7f8199a9979c9f100d754d4910d5e1bd6f929d9a.tar.gz
cpython-7f8199a9979c9f100d754d4910d5e1bd6f929d9a.tar.bz2
Merged revisions 85179 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r85179 | r.david.murray | 2010-10-02 11:58:26 -0400 (Sat, 02 Oct 2010) | 6 lines #1050268: make parseaddr 'quote' the contents of quoted strings in addresses. Also made the doc string for email._parseaddr's 'quote' function more accurate; I'd love to make the function match the old docstring instead, but other code uses it according the existing semantics. ........
Diffstat (limited to 'Lib/email/test')
-rw-r--r--Lib/email/test/test_email.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/email/test/test_email.py b/Lib/email/test/test_email.py
index 42a2ee3..e8dfbbc 100644
--- a/Lib/email/test/test_email.py
+++ b/Lib/email/test/test_email.py
@@ -2283,6 +2283,24 @@ class TestMiscellaneous(TestEmailBase):
# formataddr() quotes the name if there's a dot in it
self.assertEqual(utils.formataddr((a, b)), y)
+ def test_parseaddr_preserves_quoted_pairs_in_addresses(self):
+ # issue 10005. Note that in the third test the second pair of
+ # backslashes is not actually a quoted pair because it is not inside a
+ # comment or quoted string: the address being parsed has a quoted
+ # string containing a quoted backslash, followed by 'example' and two
+ # backslashes, followed by another quoted string containing a space and
+ # the word 'example'. parseaddr copies those two backslashes
+ # literally. Per rfc5322 this is not technically correct since a \ may
+ # not appear in an address outside of a quoted string. It is probably
+ # a sensible Postel interpretation, though.
+ eq = self.assertEqual
+ eq(utils.parseaddr('""example" example"@example.com'),
+ ('', '""example" example"@example.com'))
+ eq(utils.parseaddr('"\\"example\\" example"@example.com'),
+ ('', '"\\"example\\" example"@example.com'))
+ eq(utils.parseaddr('"\\\\"example\\\\" example"@example.com'),
+ ('', '"\\\\"example\\\\" example"@example.com'))
+
def test_multiline_from_comment(self):
x = """\
Foo