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

Decode 'htmlsrc' to string before re.sub() #14

Merged
merged 1 commit into from
Oct 30, 2020
Merged

Decode 'htmlsrc' to string before re.sub() #14

merged 1 commit into from
Oct 30, 2020

Conversation

jarkkojs
Copy link
Contributor

Python 3 has distinct types for a byte array and a string, and requires
explicit conversion between them. In order to make the script to work with
Python 3, decode 'htmlsrc' to string before applying using the re.sub() API.
Before writing the attachment to a file, encode it back to as a byte array.

Signed-off-by: Jarkko Sakkinen jarkko.sakkinen@iki.fi

Python 3 has distinct types for a byte array and a string, and requires
explicit conversion between them. In order to make the script to work with
Python 3, decode 'htmlsrc' to string before using the re.sub() API. Before
writing the attachment to a file, encode it back to a byte array.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@iki.fi>
@akkana akkana merged commit 04061c9 into akkana:master Oct 30, 2020
@akkana
Copy link
Owner

akkana commented Oct 30, 2020

Thanks! I guess I haven't been using viewhtmlmail much lately and hadn't realized it wasn't updated for python3.

@jarkkojs
Copy link
Contributor Author

NP, Otherwise seems to be working :-) Thanks for the great script! Have been using it for some (quite many) years as part of my mutt setup.

@akkana
Copy link
Owner

akkana commented Nov 8, 2020

While fixing another issue (issue #15), I realized that it would be better to decode into the default (system) charset instead of forcing UTF-8, so the latest viewhtmlmail makes that change. I think it should still work the same on any system that uses UTF-8 by default (it did in the tests I tried), but if this causes any problems for you, let me know, reopen this issue or file a new one. I also made a simple unit test for viewhtmlmail, so any charset-related problems anyone encounters from now on can be added to the unit test so they won't regress.

@jarkkojs
Copy link
Contributor Author

jarkkojs commented Nov 9, 2020

Does not cause problems, makes perfect sense. BTW, it might sense to encapsulate just this script to its own repository. There is a rise of new text based email clients like https://aerc-mail.org/. There was also one implemented in Rust of which name I cannot recall ATM.

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.

2 participants