summaryrefslogtreecommitdiffstats
path: root/Lib/email
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2012-07-23 01:53:54 (GMT)
committerR David Murray <rdmurray@bitdance.com>2012-07-23 01:53:54 (GMT)
commit970bef295d390c5ceaedca0f095590cd381a3331 (patch)
treeedcfaa0260becf3c1704f2fe17ea46d8957be0e2 /Lib/email
parent4fb6b0a104ebc2a94638100d013b1d2e917373ba (diff)
parent6a31bc6d81f42ac39868ced08d83cad880a7cce6 (diff)
downloadcpython-970bef295d390c5ceaedca0f095590cd381a3331.zip
cpython-970bef295d390c5ceaedca0f095590cd381a3331.tar.gz
cpython-970bef295d390c5ceaedca0f095590cd381a3331.tar.bz2
Merge #15232: correctly mangle From lines in MIME preamble and epilogue
Diffstat (limited to 'Lib/email')
-rw-r--r--Lib/email/generator.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/Lib/email/generator.py b/Lib/email/generator.py
index fcecf93..8413f3b 100644
--- a/Lib/email/generator.py
+++ b/Lib/email/generator.py
@@ -252,7 +252,11 @@ class Generator:
msg.set_boundary(boundary)
# If there's a preamble, write it out, with a trailing CRLF
if msg.preamble is not None:
- self.write(msg.preamble + self._NL)
+ if self._mangle_from_:
+ preamble = fcre.sub('>From ', msg.preamble)
+ else:
+ preamble = msg.preamble
+ self.write(preamble + self._NL)
# dash-boundary transport-padding CRLF
self.write('--' + boundary + self._NL)
# body-part
@@ -270,7 +274,11 @@ class Generator:
self.write(self._NL + '--' + boundary + '--')
if msg.epilogue is not None:
self.write(self._NL)
- self.write(msg.epilogue)
+ if self._mangle_from_:
+ epilogue = fcre.sub('>From ', msg.epilogue)
+ else:
+ epilogue = msg.epilogue
+ self.write(epilogue)
def _handle_multipart_signed(self, msg):
# The contents of signed parts has to stay unmodified in order to keep