summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2007-07-13 22:12:58 (GMT)
committerBarry Warsaw <barry@python.org>2007-07-13 22:12:58 (GMT)
commit81a06d42602f7f14c4b476e77c73f66ede2927cb (patch)
treeef8de3258f8065367bf7e2bf029410407feaefcd
parentfe31d77dc0b70c18f1cffa98861da3a2f995241a (diff)
downloadcpython-81a06d42602f7f14c4b476e77c73f66ede2927cb.zip
cpython-81a06d42602f7f14c4b476e77c73f66ede2927cb.tar.gz
cpython-81a06d42602f7f14c4b476e77c73f66ede2927cb.tar.bz2
In response to this SF bug:
[ 1752723 ] email.message_from_string: initial line gets discarded I added a test to assert that when the first line of text passed to message_from_string() contains a leading space, the message ends up with the appropriate FirstHeaderLineIsContinuationDefect on its defects list. The bug is invalid.
-rw-r--r--Lib/email/test/test_email.py12
-rw-r--r--Lib/email/test/test_email_renamed.py11
2 files changed, 23 insertions, 0 deletions
diff --git a/Lib/email/test/test_email.py b/Lib/email/test/test_email.py
index a032999..5a86da8 100644
--- a/Lib/email/test/test_email.py
+++ b/Lib/email/test/test_email.py
@@ -1492,6 +1492,18 @@ counter to RFC 2822, there's no separating newline here
self.failUnless(isinstance(bad.defects[0],
Errors.StartBoundaryNotFoundDefect))
+ def test_first_line_is_continuation_header(self):
+ eq = self.assertEqual
+ m = ' Line 1\nLine 2\nLine 3'
+ msg = email.message_from_string(m)
+ eq(msg.keys(), [])
+ eq(msg.get_payload(), 'Line 2\nLine 3')
+ eq(len(msg.defects), 1)
+ self.failUnless(isinstance(msg.defects[0],
+ Errors.FirstHeaderLineIsContinuationDefect))
+ eq(msg.defects[0].line, ' Line 1\n')
+
+
# Test RFC 2047 header encoding and decoding
diff --git a/Lib/email/test/test_email_renamed.py b/Lib/email/test/test_email_renamed.py
index 44238c7..37ce7af 100644
--- a/Lib/email/test/test_email_renamed.py
+++ b/Lib/email/test/test_email_renamed.py
@@ -1490,6 +1490,17 @@ counter to RFC 2822, there's no separating newline here
self.failUnless(isinstance(bad.defects[0],
errors.StartBoundaryNotFoundDefect))
+ def test_first_line_is_continuation_header(self):
+ eq = self.assertEqual
+ m = ' Line 1\nLine 2\nLine 3'
+ msg = email.message_from_string(m)
+ eq(msg.keys(), [])
+ eq(msg.get_payload(), 'Line 2\nLine 3')
+ eq(len(msg.defects), 1)
+ self.failUnless(isinstance(msg.defects[0],
+ errors.FirstHeaderLineIsContinuationDefect))
+ eq(msg.defects[0].line, ' Line 1\n')
+
# Test RFC 2047 header encoding and decoding