Comment 15 for bug 266068

Revision history for this message
Mark Sapiro (msapiro) wrote :

I have attached 77_header_folding_in_attachments_refactored.patch. This is still against the 2.1.9 base as that is where I was doing the testing but porting it forward should be trivial.

The refactored patch does three things:

It adds a Mailman/Generator.py module which is the same as that in the original patch except mangle_from_ defaults to True.

It patches Mailman/Message.py to add an as_string() override method in the Message.Message class as does the original, but it also adds an optional mangle_from_ argument which again defaults to True.

It patches the bulkdeliver function in Mailman/Handlers/SMTPDirect.py to call msg.as_string(mangle_from_=False) to generate the flatened message for mailing without mangling the from.

In addition, I left the patch to Mailman/Mailbox.py as is for its potential effect on headers in MIME format digests. As far as embedded From_ lines are concerned, I think they have to be escaped or processing the digest.mbox to produce the digest will fail. Also, failing to escape them may leave them unescaped in the archive LISTNAME.mbox/LISTNAME.mbox which would be bad.

Another issue had me scratching my head for a while. It is that all the mangle_from_ suppression may be futile. The "don't fold headers" part of the patch may be relevant anyway for messages without embedded From_ lines, but MTAs/MDAs may mangle the embedded From_ anyway even if Mailman doesn't. In my case, my test environment uses Exim as an MTA/MDA and Exim escapes From_ lines in the body somewhere between receiving the message and delivering it to a local mailbox, so even though the message left Mailman with the embedded From_ unchanged, it was ultimately escaped in my incoming mailbox.