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

dim: replace message characters leading to decoding errors with U+FFFD


The character set decoding added in commit b66d07db ("dim: decode
email message content charset to unicode") started failing with unicode
decoding failures under certain conditions. (Specifically python 3 and
mboxes downloaded from patchwork.)

Instead of raising UnicodeDecodeErrors, replace values that can't be
converted with U+FFFD (REPLACEMENT CHARACTER, �).

Reported-by: default avatarDave Airlie <airlied@gmail.com>
Cc: Dave Airlie <airlied@gmail.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
parent cc2f1ba6
No related branches found
No related tags found
No related merge requests found
Pipeline #234051 passed
......@@ -460,7 +460,7 @@ def print_msg(file):
msg = email.message_from_file(file)
for part in msg.walk():
if part.get_content_type() == 'text/plain':
print(part.get_payload(decode=True).decode(part.get_content_charset(failobj='us-ascii')))
print(part.get_payload(decode=True).decode(part.get_content_charset(failobj='us-ascii'), 'replace'))
print_msg(open('$1', 'r'))
EOF
......
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