CZ-NIC / envelope

Insert a message and attachments and send e-mail / sign / encrypt contents by a single line.
Other
171 stars 12 forks source link

Fix charset for base64 encoded content #6

Closed aisbergg closed 3 years ago

aisbergg commented 3 years ago

As explained in the comments of the source code, the ContentManager will transfer a bytes encoded string as base64 encoded content. By default it doesn't take the original utf-8 encoding into account and therefore won't add the correct email charset header. This results in special characters being displayed wrong in most email clients.

This patch sets the correct utf-8 encoding in the described cases.

e3rd commented 3 years ago

Seems amazing! Would you mind to adding a test case please? Demonstrating that the charset is / is not added. Possibly around / into test_1000_split or test_1000_split_html.

aisbergg commented 3 years ago

Yes, I will take care of writing a few tests

aisbergg commented 3 years ago

The repository doesn't contain any pytests yet, only test content for mails and gpg/smime keys. Do you have any tests laying around, that you just not yet committed? Or what kind of test shall I include for the PR?

aisbergg commented 3 years ago

Oh my, I just realized you have your tests in the root of the repo 🙄

e3rd commented 3 years ago

If you think this is a bad practice to have tests.py in the root, I'm open to your suggestions.

aisbergg commented 3 years ago

I extended the test to look for "charset" in the headers as well. I am not sure how to add a test for the opposite case now, were the "charset" header would be missing 🤔

e3rd commented 3 years ago

Thanks a lot!

e3rd commented 3 years ago

I've released a patch, thanks for collaboration.