Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 66c3d18

Browse files
committed
Merge: #14983: always add a line end after a MIME boundary marker.
2 parents 1272426 + e9c3147 commit 66c3d18

4 files changed

Lines changed: 16 additions & 7 deletions

File tree

Lib/email/generator.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,9 +299,8 @@ def _handle_multipart(self, msg):
299299
# body-part
300300
self._fp.write(body_part)
301301
# close-delimiter transport-padding
302-
self.write(self._NL + '--' + boundary + '--')
302+
self.write(self._NL + '--' + boundary + '--' + self._NL)
303303
if msg.epilogue is not None:
304-
self.write(self._NL)
305304
if self._mangle_from_:
306305
epilogue = fcre.sub('>From ', msg.epilogue)
307306
else:

Lib/test/test_email/data/msg_02.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ hello
119119

120120

121121
--__--__----
122+
122123
--192.168.1.2.889.32614.987812255.500.21814
123124
Content-type: text/plain; charset=us-ascii
124125
Content-description: Digest Footer

Lib/test/test_email/test_email.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1745,7 +1745,8 @@ def test_no_parts_in_a_multipart_with_none_epilogue(self):
17451745
17461746
--BOUNDARY
17471747
1748-
--BOUNDARY--''')
1748+
--BOUNDARY--
1749+
''')
17491750

17501751
def test_no_parts_in_a_multipart_with_empty_epilogue(self):
17511752
outer = MIMEBase('multipart', 'mixed')
@@ -1790,7 +1791,8 @@ def test_one_part_in_a_multipart(self):
17901791
Content-Transfer-Encoding: 7bit
17911792
17921793
hello world
1793-
--BOUNDARY--''')
1794+
--BOUNDARY--
1795+
''')
17941796

17951797
def test_seq_parts_in_a_multipart_with_empty_preamble(self):
17961798
eq = self.ndiffAssertEqual
@@ -1816,7 +1818,8 @@ def test_seq_parts_in_a_multipart_with_empty_preamble(self):
18161818
Content-Transfer-Encoding: 7bit
18171819
18181820
hello world
1819-
--BOUNDARY--''')
1821+
--BOUNDARY--
1822+
''')
18201823

18211824

18221825
def test_seq_parts_in_a_multipart_with_none_preamble(self):
@@ -1842,7 +1845,8 @@ def test_seq_parts_in_a_multipart_with_none_preamble(self):
18421845
Content-Transfer-Encoding: 7bit
18431846
18441847
hello world
1845-
--BOUNDARY--''')
1848+
--BOUNDARY--
1849+
''')
18461850

18471851

18481852
def test_seq_parts_in_a_multipart_with_none_epilogue(self):
@@ -1868,7 +1872,8 @@ def test_seq_parts_in_a_multipart_with_none_epilogue(self):
18681872
Content-Transfer-Encoding: 7bit
18691873
18701874
hello world
1871-
--BOUNDARY--''')
1875+
--BOUNDARY--
1876+
''')
18721877

18731878

18741879
def test_seq_parts_in_a_multipart_with_empty_epilogue(self):

Misc/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ Core and Builtins
2727
Library
2828
-------
2929

30+
- Issue #14983: email.generator now always adds a line end after each MIME
31+
boundary marker, instead of doing so only when there is an epilogue. This
32+
fixes an RFC compliance bug and solves an issue with signed MIME parts.
33+
3034
- Issue #20540: Fix a performance regression (vs. Python 3.2) when layering
3135
a multiprocessing Connection over a TCP socket. For small payloads, Nagle's
3236
algorithm would introduce idle delays before the entire transmission of a

0 commit comments

Comments
 (0)