[issue27321] Email parser creates a message object that can't be flattened

Mark Sapiro report at bugs.python.org
Tue Jun 14 18:54:21 EDT 2016


Mark Sapiro added the comment:

One additional observation. The original message contained no Content-Transfer-Encoding header even though the message body was raw koi8-r characters. Adding

Content-Transfer-Encoding: 8bit

to the message headers avoids the issue, but that is not a practical solution as the message was Russian spam received by a Mailman list and the resultant KeyError caused problems in Mailman.

We can work on defending against this in Mailman, but I suggest that the munge_cte code in generator._write() avoid the documented possible KeyError raised by replace_header() by using __delitem__() and __setitem__() instead as in the attached generator.patch.

----------
keywords: +patch
Added file: http://bugs.python.org/file43394/generator.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27321>
_______________________________________


More information about the Python-bugs-list mailing list