Skip to content
Snippets Groups Projects
Commit d79c5784 authored by Simon Ser's avatar Simon Ser Committed by Simona Vetter
Browse files

dim: fix handling of 8-bit non-UTF-8 messages


Python's open() function will return a file object that decodes input
bytes to an UTF-8 string. Python assumes all files are UTF-8 by default
(unless an explicit encoding param is passed).

This works fine with 7-bit and UTF-8 messages. However, when a message
uses a 8-bit Content-Transfer-Encoding and a non-UTF-8 charset (such as
iso-8859-1), Python will error out.

To prevent this, open the file in binary mode to prevent Python from
doing any charset conversion under-the-hood.

Signed-off-by: Simon Ser's avatarSimon Ser <contact@emersion.fr>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 45b9167f
No related branches found
No related tags found
No related merge requests found
Pipeline #244312 passed
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