Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't decode messages before substitution #22

Merged
merged 1 commit into from
Nov 24, 2022

Conversation

hjerning
Copy link
Contributor

@hjerning hjerning commented Oct 17, 2022

Without this patch I'm unable to open iso-8859-1 and iso-8859-15 encoded emails with åäö in them are garbled.

Fixes #21.

When decoding the message from bytes to an UTF-8 string and replacing
characters that couldn't be decoded - characters from some encodings will
be lost when encoding it to bytes again, do the regex on the byte data
instead.

Also make sure all three different input methods (Maildir, File and
stdin) use BytesParser as introduced in 5db80f1.
@hjerning
Copy link
Contributor Author

hjerning commented Nov 2, 2022

First of all, thanks for this excellent tool! I have been using it since 2e84ba9.

Your change last week to use BytesParser instead of message_from_string made some of the initial PR redundant, so I have adapted it to use BytesParser instead of message_from_bytes now.

The part to skip decode(errors="replace") is still valid though, and without it iso-8859-15 encoded emails look very ugly.

@hjerning hjerning changed the title Open messages as binary files Don't decode messages before substitution Nov 2, 2022
@akkana akkana merged commit 519a228 into akkana:master Nov 24, 2022
@akkana
Copy link
Owner

akkana commented Nov 24, 2022

Thanks! I don't get that much mail with nonascii encodings (and what I do get is often encoded improperly, from people copy/pasting across different apps), so it's super helpful to get patches like this. And thanks for reminding me; I sometimes get swamped keeping track of emails and forget that I have an issue that I need to attend to.

@hjerning hjerning deleted the message_from_bytes branch November 25, 2022 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

viewhtmlmail.py fails for certain characters
2 participants