diff options
author | R. David Murray <rdmurray@bitdance.com> | 2010-01-16 05:15:17 +0000 |
---|---|---|
committer | R. David Murray <rdmurray@bitdance.com> | 2010-01-16 05:15:17 +0000 |
commit | ed44dfa4c7dd03488da6e23c9901af7185af8302 (patch) | |
tree | 190b9cba0b769cd8cc063e68dee9a1ddbbbe423e /Lib/email/generator.py | |
parent | 57cd8ebc2034d0e2a1ca51b84267346b5d6ded34 (diff) | |
download | cpython-git-ed44dfa4c7dd03488da6e23c9901af7185af8302.tar.gz |
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.
Diffstat (limited to 'Lib/email/generator.py')
-rw-r--r-- | Lib/email/generator.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/email/generator.py b/Lib/email/generator.py index 77d44bef9b..bcb0a49887 100644 --- a/Lib/email/generator.py +++ b/Lib/email/generator.py @@ -237,6 +237,17 @@ class Generator: print >> 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 |