[ python-Bugs-1078919 ] Email.Header encodes non-ASCII content incorrectly

SourceForge.net noreply at sourceforge.net
Sun Dec 5 20:42:19 CET 2004


Bugs item #1078919, was opened at 2004-12-04 16:47
Message generated for change (Comment added) made by loewis
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1078919&group_id=5470

Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Tessa Lau (tlau)
Assigned to: Nobody/Anonymous (nobody)
Summary: Email.Header encodes non-ASCII content incorrectly

Initial Comment:
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.

----------------------------------------------------------------------

>Comment By: Martin v. Löwis (loewis)
Date: 2004-12-05 20:42

Message:
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.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1078919&group_id=5470


More information about the Python-bugs-list mailing list