Bug getting i18n'ed attachment filenames (RFC2231)
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
| GNU Mailman |
High
|
Barry Warsaw |
Bug Description
RFC 2231 allows filenames to have non-ascii characters. The get_filename() method in Python's Message class handles this by calling email.utils.
This fails in Mailman because the mailman.
File "/usr/lib/
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_
Does this make sense ? Any other idea for a possible solution ?
Related branches
- Barry Warsaw: Approve on 2014-12-09
-
Diff: 268 lines (+68/-42)13 files modifiedsrc/mailman/app/bounces.py (+4/-1)
src/mailman/app/moderator.py (+3/-3)
src/mailman/archiving/mailarchive.py (+2/-0)
src/mailman/archiving/mhonarc.py (+2/-0)
src/mailman/archiving/prototype.py (+2/-0)
src/mailman/commands/docs/unshunt.rst (+1/-1)
src/mailman/commands/eml_membership.py (+2/-0)
src/mailman/email/message.py (+9/-35)
src/mailman/email/tests/test_message.py (+33/-1)
src/mailman/model/bounce.py (+4/-1)
src/mailman/model/messagestore.py (+2/-0)
src/mailman/rules/implicit_dest.py (+2/-0)
src/mailman/utilities/email.py (+2/-0)
tags: | added: mailman3 |
Aurélien Bompard (abompard) wrote : | #1 |
Mark Sapiro (msapiro) wrote : | #2 |
This works for me with Mailman 2.1.15 and email 4.0.1. Does it fail for you with Mailman 2.1.x? If so, what Mailman and email versions?
[msapiro@MSAPIRO ~]$ python
Python 2.6.5 (r265:79063, Jun 12 2010, 17:07:01)
[GCC 4.3.4 20090804 (release) 1] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import email
>>> email.__version__
'4.0.1'
>>> import sys
>>> sys.path.
>>> from Mailman import Message
>>> msg = email.message_
... Content-Type: multipart/mixed; boundary=
...
... This is a multi-part message in MIME format.
... -------
... Content-Type: text/plain; charset=UTF-8
... Content-
...
... Test message containing an attachment with an accented filename
...
... -------
... Content-Type: text/plain; charset=UTF-8;
... name="=
... Content-
... Content-
... filename*
...
... VmlhbmRlCk1lbnR
... b3VwZXIgZXQgZmF
... aWVzCg==
... -------
... """, Message.Message)
>>> msg
From nobody Wed Oct 3 08:43:13 2012
Message-ID: <email address hidden>
Content-Type: multipart/mixed; boundary=
This is a multi-part message in MIME format.
-------
Content-Type: text/plain; charset=UTF-8
Content-
Test message containing an attachment with an accented filename
-------
Content-Type: text/plain; charset=UTF-8;
Content-
Content-
VmlhbmRlCk1lbnR
b3VwZXIgZXQgZmF
aWVzCg==
-------
>>> att = msg.get_
>>> att
From nobody Wed Oct 3 08:43:44 2012
Content-Type: text/plain; charset=UTF-8;
Content-
Content-
VmlhbmRlCk1lbnR
b3VwZXIgZXQgZmF
aWVzCg==
>>> att.get_filename()
u'todo-
Aurélien Bompard (abompard) wrote : | #3 |
Sorry, I should have written it : it's with Mailman 3 HEAD.
no longer affects: | mailman/2.1 |
no longer affects: | mailman/3.0 |
Changed in mailman: | |
milestone: | none → 3.0.0b5 |
assignee: | nobody → Barry Warsaw (barry) |
importance: | Undecided → High |
status: | New → Fix Committed |
Changed in mailman: | |
status: | Fix Committed → Fix Released |
See the TestMessageSubclass testcase I've added to the attached testsuite for a way to reproduce it.
It's actually a little harder that I first thought, encoding the filename in the middle of the method is not enough.