[New-bugs-announce] [issue8769] Straightforward usage of email package fails to round-trip
report at bugs.python.org
Wed May 19 22:55:19 CEST 2010
New submission from A.M. Kuchling <lists at amk.ca>:
The attached test program shows how parsing an e-mail message with the email package, then converting the resulting message to a string, fails to round-trip properly. Instead it breaks the encoding of the subject line.
The root of the problem: the subject is RFC-2047 quoted, long enough to require line wrapping, and it contains one of the splitchars used by Header.encode() -- meaning a semi-colon or comma. In my example, this is:
Parsing the message turns that into a string S. generator.Generator._write_headers() then outputs Header(S).encode(), so it keeps treating the value as an ASCII string, and therefore breaks the header at the semicolon, resulting in:
Newline and space aren't legal in Q encoding, so MUAs give up and display all the =?utf-8?Q? stuff.
components: Library (Lib)
nosy: akuchling, barry
title: Straightforward usage of email package fails to round-trip
versions: Python 2.7
Added file: http://bugs.python.org/file17410/email-roundtrip-failure.py
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce