diff options
author | Simon Chopin <chopin.simon@gmail.com> | 2013-08-13 10:58:26 +0200 |
---|---|---|
committer | Simon Chopin <chopin.simon@gmail.com> | 2013-08-13 10:58:26 +0200 |
commit | 947f5eb80f0cff20f82ea1cc5442d473cef744cb (patch) | |
tree | edee346ddbc452fa935674696f5b57b482481d62 | |
parent | 4183ba5acf8b3d292dbe53a52a98e50ee3324b3a (diff) |
db.utils: Use unicode for GPG error messages
This patch makes the use of unicode more consistent, and enforces the
UTF8 charset for the added payload in case of failure.
-rw-r--r-- | alot/db/utils.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/alot/db/utils.py b/alot/db/utils.py index 7fb2deba..cfca8c4b 100644 --- a/alot/db/utils.py +++ b/alot/db/utils.py @@ -125,7 +125,7 @@ def message_from_file(handle): sigs = crypto.verify_detached(m.get_payload(0).as_string(), m.get_payload(1).get_payload()) except GPGProblem as e: - malformed = str(e) + malformed = unicode(e) add_signature_headers(m, sigs, malformed) @@ -160,7 +160,7 @@ def message_from_file(handle): # the combined method is used, currently this prevents # the interpretation of the recovered plain text # mail. maybe that's a feature. - malformed = str(e) + malformed = unicode(e) else: # parse decrypted message n = message_from_string(d) @@ -200,7 +200,9 @@ def message_from_file(handle): if malformed: msg = u'Malformed OpenPGP message: {0}'.format(malformed) - m.attach(email.message_from_string(msg)) + content = email.message_from_string(msg.encode('utf-8')) + content.set_charset('utf-8') + m.attach(content) return m |