From 24d45df3f2a4e549fc115a77a250a98861c06750 Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Tue, 10 Sep 2002 15:46:44 +0000 Subject: [PATCH] test_splitting_first_line_only_is_long(): New test for SF bug #601392, broken wrapping of long ASCII headers. --- Lib/email/test/test_email.py | 39 +++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/Lib/email/test/test_email.py b/Lib/email/test/test_email.py index 8a9759cfc4a..0fe304b3323 100644 --- a/Lib/email/test/test_email.py +++ b/Lib/email/test/test_email.py @@ -687,6 +687,22 @@ from babylon.socal-raves.org (localhost [127.0.0.1]); \tfor ; \tSat, 2 Feb 2002 17:00:06 -0800 (PST)""") + def test_splitting_first_line_only_is_long(self): + eq = self.ndiffAssertEqual + hstr = """\ +from modemcable093.139-201-24.que.mc.videotron.ca ([24.201.139.93] helo=cthulhu.gerg.ca) +\tby kronos.mems-exchange.org with esmtp (Exim 4.05) +\tid 17k4h5-00034i-00 +\tfor test@mems-exchange.org; Wed, 28 Aug 2002 11:25:20 -0400""" + h = Header(hstr, maxlinelen=78, header_name='Received', + continuation_ws='\t') + eq(h.encode(), """\ +from modemcable093.139-201-24.que.mc.videotron.ca ([24.201.139.93] +\thelo=cthulhu.gerg.ca) +\tby kronos.mems-exchange.org with esmtp (Exim 4.05) +\tid 17k4h5-00034i-00 +\tfor test@mems-exchange.org; Wed, 28 Aug 2002 11:25:20 -0400""") + # Test mangling of "From " lines in the body of a message @@ -1011,7 +1027,7 @@ class TestNonConformant(TestEmailBase): data = fp.read() finally: fp.close() - p = Parser() + p = Parser(strict=1) # Note, under a future non-strict parsing mode, this would parse the # message into the intended message tree. self.assertRaises(Errors.BoundaryError, p.parsestr, data) @@ -1045,6 +1061,23 @@ class TestNonConformant(TestEmailBase): g.flatten(msg) neq(s.getvalue(), 'Content-Type: foo\n\n') + def test_no_start_boundary(self): + eq = self.ndiffAssertEqual + msg = self._msgobj('msg_31.txt') + eq(msg.get_payload(), """\ +--BOUNDARY +Content-Type: text/plain + +message 1 + +--BOUNDARY +Content-Type: text/plain + +message 2 + +--BOUNDARY-- +""") + # Test RFC 2047 header encoding and decoding @@ -1428,6 +1461,10 @@ class TestIdempotent(TestEmailBase): msg, text = self._msgobj('msg_24.txt') self._idempotent(msg, text) + def test_no_start_boundary(self): + msg, text = self._msgobj('msg_31.txt') + self._idempotent(msg, text) + def test_content_type(self): eq = self.assertEquals unless = self.failUnless