From 06b8ec96140646076e1fb5b40824cb64db97753a Mon Sep 17 00:00:00 2001 From: Borja Lopez Date: Wed, 20 Feb 2019 21:04:08 +0100 Subject: [PATCH 1/2] Replaced Message.get_charset() with Message.get_content_charset(): Fixes the bug described here: https://github.com/repoze/repoze.sendmail/issues/41 Rationale: get_content_charset() has been there in email.message.Message for a long time now, returning the charset of the body of the Message (which is what we are looking for there). get_charset() has been deprecated for some time now, returns None by default (even if a charset is set in the Content-Type header). There are some other ways to retrieve the charset (get_params(), get_param('charset'), message['Content-Type'].params) but get_content_charset() is the only one that exists through all existing python versions, and it is there even in the new email.message.EmailMessage class. --- repoze/sendmail/encoding.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repoze/sendmail/encoding.py b/repoze/sendmail/encoding.py index 03fff54..855e8a4 100644 --- a/repoze/sendmail/encoding.py +++ b/repoze/sendmail/encoding.py @@ -71,7 +71,7 @@ def cleanup_message(message, payload = message.get_payload() if payload and isinstance(payload, text_type): - charset = message.get_charset() + charset = message.get_content_charset() if not charset: charset, encoded = best_charset(payload) message.set_payload(payload, charset=charset) From a5d86c80ae9702f0b1e2b4b77c03f5a4bd06ae58 Mon Sep 17 00:00:00 2001 From: Borja Lopez Date: Wed, 20 Feb 2019 21:13:52 +0100 Subject: [PATCH 2/2] Updated version to 4.4.2 (bugfix release) --- CHANGES.rst | 6 ++++++ setup.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 3bb717e..e8bbf2a 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -6,6 +6,12 @@ Change history - TBD +4.4.2 (2019-02-20) +------------------ + +- Fix setting charset for attached messages in a multipart/alternative message + (issue #41) + 4.4.1 (2017-04-21) ------------------ diff --git a/setup.py b/setup.py index c7455ab..80ee0c8 100644 --- a/setup.py +++ b/setup.py @@ -33,7 +33,7 @@ def _read_file(filename): CHANGES = _read_file('CHANGES.rst') setup(name='repoze.sendmail', - version = '4.5.dev0', + version = '4.4.2', url='http://www.repoze.org', license='ZPL 2.1', description='Repoze Sendmail',