diff options
Diffstat (limited to 'Lib/email/test/test_email.py')
-rw-r--r-- | Lib/email/test/test_email.py | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/Lib/email/test/test_email.py b/Lib/email/test/test_email.py index 0d7e79f..1749102 100644 --- a/Lib/email/test/test_email.py +++ b/Lib/email/test/test_email.py @@ -2307,7 +2307,7 @@ class TestParsers(TestEmailBase): self.failIf(msg.is_multipart()) self.failUnless(isinstance(msg.get_payload(), str)) - def test_whitespace_continuaton(self): + def test_whitespace_continuation(self): eq = self.assertEqual # This message contains a line after the Subject: header that has only # whitespace, but it is not empty! @@ -2325,6 +2325,24 @@ Here's the message body eq(msg['message-id'], 'spam') eq(msg.get_payload(), "Here's the message body\n") + def test_whitespace_continuation_last_header(self): + eq = self.assertEqual + # Like the previous test, but the subject line is the last + # header. + msg = email.message_from_string("""\ +From: aperson@dom.ain +To: bperson@dom.ain +Date: Mon, 8 Apr 2002 15:09:19 -0400 +Message-ID: spam +Subject: the next line has a space on it +\x20 + +Here's the message body +""") + eq(msg['subject'], 'the next line has a space on it\n ') + eq(msg['message-id'], 'spam') + eq(msg.get_payload(), "Here's the message body\n") + def test_crlf_separation(self): eq = self.assertEqual fp = openfile('msg_26.txt', mode='rb') @@ -2381,6 +2399,17 @@ Here's the message body msg = email.message_from_string(NL.join(lines)) self.assertEqual(msg['date'], 'Tue, 20 Aug 2002 16:43:45 +1000') + def test_strip_line_feed_and_carriage_return_in_headers(self): + eq = self.assertEqual + # For [ 1002475 ] email message parser doesn't handle \r\n correctly + value1 = 'text' + value2 = 'more text' + m = 'Header: %s\r\nNext-Header: %s\r\n\r\nBody\r\n\r\n' % ( + value1, value2) + msg = email.message_from_string(m) + eq(msg.get('Header'), value1) + eq(msg.get('Next-Header'), value2) + class TestBase64(unittest.TestCase): |