Public bug reported:

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).

** Affects: mailman
     Importance: Undecided
         Status: New


** Tags: mailman3

** Patch added: "mailman-digestunicode.patch"
   
https://bugs.launchpad.net/bugs/1170347/+attachment/3647526/+files/mailman-digestunicode.patch

-- 
You received this bug notification because you are a member of Mailman
Coders, which is subscribed to GNU Mailman.
https://bugs.launchpad.net/bugs/1170347

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

To manage notifications about this bug go to:
https://bugs.launchpad.net/mailman/+bug/1170347/+subscriptions
_______________________________________________
Mailman-coders mailing list
[email protected]
http://mail.python.org/mailman/listinfo/mailman-coders

Reply via email to