(original) (raw)

changeset: 89068:c2538789c8cf branch: 3.3 parent: 89065:a8a6dc7f478b user: R David Murray rdmurray@bitdance.com date: Sat Feb 08 17:54:56 2014 -0500 files: Lib/email/generator.py Lib/test/test_email/data/msg_02.txt Lib/test/test_email/test_email.py Misc/NEWS description: #14983: always add a line end after a MIME boundary marker. This is more RFC compliant (see issue) and fixes a problem with signature verifiers rejecting the part when signed. There is some amount of backward compatibility concern here since it changes the output, but the RFC issue coupled with fixing the problem with signature verifiers seems worth the small risk of breaking code that depends on the current incorrect output. diff -r a8a6dc7f478b -r c2538789c8cf Lib/email/generator.py --- a/Lib/email/generator.py Sat Feb 08 14:28:03 2014 -0800 +++ b/Lib/email/generator.py Sat Feb 08 17:54:56 2014 -0500 @@ -299,9 +299,8 @@ # body-part self._fp.write(body_part) # close-delimiter transport-padding - self.write(self._NL + '--' + boundary + '--') + self.write(self._NL + '--' + boundary + '--' + self._NL) if msg.epilogue is not None: - self.write(self._NL) if self._mangle_from_: epilogue = fcre.sub('>From ', msg.epilogue) else: diff -r a8a6dc7f478b -r c2538789c8cf Lib/test/test_email/data/msg_02.txt --- a/Lib/test/test_email/data/msg_02.txt Sat Feb 08 14:28:03 2014 -0800 +++ b/Lib/test/test_email/data/msg_02.txt Sat Feb 08 17:54:56 2014 -0500 @@ -119,6 +119,7 @@ --__--__---- + --192.168.1.2.889.32614.987812255.500.21814 Content-type: text/plain; charset=us-ascii Content-description: Digest Footer diff -r a8a6dc7f478b -r c2538789c8cf Lib/test/test_email/test_email.py --- a/Lib/test/test_email/test_email.py Sat Feb 08 14:28:03 2014 -0800 +++ b/Lib/test/test_email/test_email.py Sat Feb 08 17:54:56 2014 -0500 @@ -1711,7 +1711,8 @@ --BOUNDARY ---BOUNDARY--''') +--BOUNDARY-- +''') def test_no_parts_in_a_multipart_with_empty_epilogue(self): outer = MIMEBase('multipart', 'mixed') @@ -1756,7 +1757,8 @@ Content-Transfer-Encoding: 7bit hello world ---BOUNDARY--''') +--BOUNDARY-- +''') def test_seq_parts_in_a_multipart_with_empty_preamble(self): eq = self.ndiffAssertEqual @@ -1782,7 +1784,8 @@ Content-Transfer-Encoding: 7bit hello world ---BOUNDARY--''') +--BOUNDARY-- +''') def test_seq_parts_in_a_multipart_with_none_preamble(self): @@ -1808,7 +1811,8 @@ Content-Transfer-Encoding: 7bit hello world ---BOUNDARY--''') +--BOUNDARY-- +''') def test_seq_parts_in_a_multipart_with_none_epilogue(self): @@ -1834,7 +1838,8 @@ Content-Transfer-Encoding: 7bit hello world ---BOUNDARY--''') +--BOUNDARY-- +''') def test_seq_parts_in_a_multipart_with_empty_epilogue(self): diff -r a8a6dc7f478b -r c2538789c8cf Misc/NEWS --- a/Misc/NEWS Sat Feb 08 14:28:03 2014 -0800 +++ b/Misc/NEWS Sat Feb 08 17:54:56 2014 -0500 @@ -48,6 +48,10 @@ Library ------- +- Issue #14983: email.generator now always adds a line end after each MIME + boundary marker, instead of doing so only when there is an epilogue. This + fixes an RFC compliance bug and solves an issue with signed MIME parts. + - Issue #20540: Fix a performance regression (vs. Python 3.2) when layering a multiprocessing Connection over a TCP socket. For small payloads, Nagle's algorithm would introduce idle delays before the entire transmission of a /rdmurray@bitdance.com