This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author flavio
Recipients barry, flavio, r.david.murray
Date 2014-10-18.13:08:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1413637685.41.0.262065905558.issue22666@psf.upfronthosting.co.za>
In-reply-to
Content
When trying to encode an email header with a newline in it, correct encoding is done only for strings and not for unicode strings.
In fact, for unicode strings, encoding is only done if a non ascii character is contained in it.

The attached patch should fix the problem.

Simple example to reproduce the problem:
>>> from email.Header import Header as H

# correctly encoded
>>> H('two\r\nlines', 'utf-8').encode()
'=?utf-8?q?two=0D=0Alines?='

# unicode string not encoded
>>> H(u'two\r\nlines', 'utf-8').encode()
'two\r\nlines'

# unicode string with non ascii chars, correctly encoded
>>> H(u'two\r\nlines and \xe0', 'utf-8').encode()
'=?utf-8?b?dHdvDQpsaW5lcyBhbmQgw6A=?='
History
Date User Action Args
2014-10-18 13:08:05flaviosetrecipients: + flavio, barry, r.david.murray
2014-10-18 13:08:05flaviosetmessageid: <1413637685.41.0.262065905558.issue22666@psf.upfronthosting.co.za>
2014-10-18 13:08:05flaviolinkissue22666 messages
2014-10-18 13:08:05flaviocreate