Skip to content
Snippets Groups Projects
Commit b66d07db authored by Jani Nikula's avatar Jani Nikula
Browse files

dim: decode email message content charset to unicode


Email messages need two levels of decoding: First, content transfer
encoding, such as base64 or quoted-printable. Second, charset decoding.

We've done the first (with part.get_payload(decode=True)), but we've
ignored the charset. Mostly, it has not mattered, since most email is
ascii or utf-8 anyway, and python2 has been relaxed about it. However,
python3 part.get_payload(decode=True) gives us binary instead of
unicode, so we also need to do the charset decoding to get the result we
want.

The problem has likely been observed only now that 'python' no longer
exists or points at python3 instead of python2.

Use part.get_content_charset() for charset decoding, defaulting to
'us-ascii' source charset if nothing is specified.

Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Reviewed-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
Tested-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
parent 2855d165
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment