email: Fix _flatten() implementation for non-ASCII bodies
authorW. Trevor King <wking@tremily.us>
Thu, 24 Jan 2013 04:41:50 +0000 (23:41 -0500)
committerW. Trevor King <wking@tremily.us>
Thu, 24 Jan 2013 04:49:49 +0000 (23:49 -0500)
commit8a907f9ff29020bad0471adc5a12df2dff785789
tree3c278131045551ab444a63986a333a89af2af05d
parent9058a3a5b36067b4408ebedc0f406e6390ed7fb7
email: Fix _flatten() implementation for non-ASCII bodies

The email header should be flattened to ASCII with funky encoded
headers [1], but the body may be encoded in a non-ASCII-compatible
charset (e.g. UTF-16-LE).  The old _flatten() implementation used the
body charset to encode the entire message, which could garble the
header.  This patch uses BytesGenerator, which takes advantage of
email.charset.Charset's separate fields for the header encoding and
body encoding.

[1]: http://docs.python.org/3/library/email.header.html

Signed-off-by: W. Trevor King <wking@tremily.us>
rss2email/email.py