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

Bug #1170347 reported by Aurélien Bompard
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
GNU Mailman
Fix Released
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).

Tags: mailman3

Related branches

Revision history for this message
Aurélien Bompard (abompard) wrote :
Revision history for this message
Aurélien Bompard (abompard) wrote :

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

Revision history for this message
Aurélien Bompard (abompard) wrote :

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

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

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.