Digest handler crashes on non-ascii messages with no encoding header

Bug #1170347 reported by Aurélien Bompard on 2013-04-18
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
GNU Mailman
High
Barry Warsaw

Bug Description

I found an interesting bug in the to_digest handler: when a message is not ascii only but has no encoding defined (which happens in the wild unfortunately), the mailbox will crash when adding the message on line 58 of handlers/to_digest.py.
The reason is that due to the mailman-specific email.message.Message modifications, some of the headers are unicode strings. As a consequence, when the mailbox.add code from the standard library serializes the email, it merges unicode strings with bytestrings, which result in an unicode string. If this string contains non-ascii characters, python will raise an UnicodeDecodeError doing so.
The solution for that is to call the as_string() method before adding to the mailbox, it will do the serialization properly.

I'm attaching the fix (one-liner) and a testcase to reproduce it (much larger).

Related branches

Aurélien Bompard (abompard) wrote :
Aurélien Bompard (abompard) wrote :

Oops there was a typo in my patch, sorry about that. Here's the new one

Aurélien Bompard (abompard) wrote :

I've pushed the fix in my branch: lp:~abompard/mailman/bug-1170347 (merge proposal sent).

Barry Warsaw (barry) on 2014-11-29
Changed in mailman:
milestone: none → 3.0.0b5
assignee: nobody → Barry Warsaw (barry)
importance: Undecided → High
Barry Warsaw (barry) on 2014-11-29
Changed in mailman:
status: New → Fix Committed
Barry Warsaw (barry) on 2014-12-30
Changed in mailman:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers