]> granicus.if.org Git - python/commitdiff
In response to this SF bug:
authorBarry Warsaw <barry@python.org>
Fri, 13 Jul 2007 21:20:38 +0000 (21:20 +0000)
committerBarry Warsaw <barry@python.org>
Fri, 13 Jul 2007 21:20:38 +0000 (21:20 +0000)
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.

Lib/email/test/test_email.py
Lib/email/test/test_email_renamed.py

index a03299991ef92653c90763afee9ed9c441332cb0..5a86da8a3c3790ec267106611e9032aea23c79af 100644 (file)
@@ -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')
+
+
 
 \f
 # Test RFC 2047 header encoding and decoding
index 44238c78f8c4c468ead5d1f4cbb5cfda06e4f5c3..37ce7af26fb584fa97da7c3b8bfb86f96972b3ce 100644 (file)
@@ -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')
+
 
 \f
 # Test RFC 2047 header encoding and decoding