[Bug 1060951] [NEW] Bug getting i18n'ed attachment filenames (RFC2231)

Aurélien Bompard aurelien at bompard.org
Wed Oct 3 15:25:32 CEST 2012

Public bug reported:

RFC 2231 allows filenames to have non-ascii characters. The
get_filename() method in Python's Message class handles this by calling
email.utils.collapse_rfc2231_value() at the end of get_filename. This
method returns the filename in Unicode.

This fails in Mailman because the mailman.email.message.Message class
has a wrapper around get() and __getitem__() to return unicode headers.
As a result, the collapse_rfc2231_value() tries to transforms into
unicode an already unicode string, and I get the following exception:

  File "/usr/lib/python2.7/email/utils.py", line 319, in collapse_rfc2231_value
    return unicode(rawval, charset, errors)
TypeError: decoding Unicode is not supported

A possible solution to this would be to make Mailman's Message
get_filename() method be more than just an exception-catching wrapper,
and re-implement the original get_filename() method, inserting a
conversion to str before calling collapse_rfc2231_value().

Does this make sense ? Any other idea for a possible solution ?

** Affects: mailman
     Importance: Undecided
         Status: New

You received this bug notification because you are a member of Mailman
Coders, which is subscribed to GNU Mailman.

  Bug getting i18n'ed attachment filenames (RFC2231)

To manage notifications about this bug go to:

More information about the Mailman-coders mailing list