classification
Title: Email.Header encodes non-ASCII content incorrectly
Type: feature request Stage: test needed
Components: Library (Lib) Versions: Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: barry Nosy List: ajaksu2, barry, loewis, tlau (4)
Priority: normal Keywords easy

Created on 2004-12-04 15:47 by tlau, last changed 2009-04-22 16:03 by ajaksu2.

Messages (3)
msg23536 - (view) Author: Tessa Lau (tlau) Date: 2004-12-04 15:47
I'm generating a MIME message with an attachment whose
filename includes non-ASCII characters.  I create the
MIME header as follows:

msg.add_header('Content-Disposition', 'attachment',
filename=u'Fu\xdfballer_sind_klug.ppt')

The Python-generated header looks like this:

Content-disposition:
=?utf-8?b?YXR0YWNobWVudDsgZmlsZW5hbWU9IkZ1w59iYWxsZXJf?=
        =?utf-8?q?sind=5Fklug=2Eppt=22?=

I sent messages with this header to Gmail, evolution,
and thunderbird, and none of them correctly decode that
header to suggest the correct default filename. 
However, I've found that those three mailers do behave
correctly when the header looks like this instead:

Content-disposition: attachment;
filename="=?iso-8859-1?q?Fu=DFballer=5Fsind=5Fklug=2Eppt?="

Is there a way to make Python's email module generate a
Content-disposition header that works with common MUAs?
 I know I can manually encode the filename before
passing it to add_header(), but it seems that Python
should be doing this for me.
msg23537 - (view) Author: Martin v. Löwis (loewis) Date: 2004-12-05 19:42
Logged In: YES 
user_id=21627

The fact that neither Gmail, evolution, or thunderbird can
decode this string properly does not mean that Python
encodes it incorrectly. I cannot see an error in this header
- although I can sympathize with the developers of the MUAs
that this is a non-obvious usage of the standards.

So I recommend you report this as a bug to the authors of
the MUAs.
msg82125 - (view) Author: Daniel Diniz (ajaksu2) Date: 2009-02-14 22:21
The proposed output has the virtue of being easier to read.
History
Date User Action Args
2009-04-22 16:03:19ajaksu2setkeywords: + easy
2009-03-30 22:56:23ajaksu2linkissue1685453 dependencies
2009-02-14 22:21:53ajaksu2setnosy: + ajaksu2
stage: test needed
type: feature request
messages: + msg82125
versions: + Python 2.7, - Python 2.4
2004-12-04 15:47:34tlaucreate