summaryrefslogtreecommitdiffstats
path: root/Lib/email/generator.py
diff options
context:
space:
mode:
authorR. David Murray <rdmurray@bitdance.com>2010-01-16 18:41:00 (GMT)
committerR. David Murray <rdmurray@bitdance.com>2010-01-16 18:41:00 (GMT)
commitfa606926d6386b601472ebf5e7c23ae47320788c (patch)
treea73df73d8893994ce5ec827bde4d5defa06250f5 /Lib/email/generator.py
parent11f657843fdc8bf28a3c86595a5ec12be7a9bdf3 (diff)
downloadcpython-fa606926d6386b601472ebf5e7c23ae47320788c.zip
cpython-fa606926d6386b601472ebf5e7c23ae47320788c.tar.gz
cpython-fa606926d6386b601472ebf5e7c23ae47320788c.tar.bz2
Merged revisions 77542 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ................ r77542 | r.david.murray | 2010-01-16 13:30:03 -0500 (Sat, 16 Jan 2010) | 18 lines Merged revisions 77517,77525 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk Merge adds an additional test for as_string with a maxheaderlen specified. ........ r77517 | r.david.murray | 2010-01-16 00:15:17 -0500 (Sat, 16 Jan 2010) | 6 lines Issue #1670765: Prevent email.generator.Generator from re-wrapping headers in multipart/signed MIME parts, which fixes one of the sources of invalid modifications to such parts by Generator. Patch and tests by Martin von Gagern. ........ r77525 | r.david.murray | 2010-01-16 11:08:32 -0500 (Sat, 16 Jan 2010) | 2 lines Fix issue number in comment. ........ ................
Diffstat (limited to 'Lib/email/generator.py')
-rw-r--r--Lib/email/generator.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/email/generator.py b/Lib/email/generator.py
index e821d00..61521b8 100644
--- a/Lib/email/generator.py
+++ b/Lib/email/generator.py
@@ -215,6 +215,17 @@ class Generator:
print(file=self._fp)
self._fp.write(msg.epilogue)
+ def _handle_multipart_signed(self, msg):
+ # The contents of signed parts has to stay unmodified in order to keep
+ # the signature intact per RFC1847 2.1, so we disable header wrapping.
+ # RDM: This isn't enough to completely preserve the part, but it helps.
+ old_maxheaderlen = self._maxheaderlen
+ try:
+ self._maxheaderlen = 0
+ self._handle_multipart(msg)
+ finally:
+ self._maxheaderlen = old_maxheaderlen
+
def _handle_message_delivery_status(self, msg):
# We can't just write the headers directly to self's file object
# because this will leave an extra newline between the last header