summaryrefslogtreecommitdiff
path: root/alot/db/utils.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2017-07-14 15:14:40 -0700
committerDylan Baker <dylan@pnwbakers.com>2017-07-24 16:41:42 -0700
commit55f7d0dbf14c63754b61c5986e857f1f30bf1ba9 (patch)
tree7a55b6320e92f5fe1cf5dee7df8a7c8b81821d58 /alot/db/utils.py
parent9133904bd7d376e18a0e3ce36de4438814893cbc (diff)
db/utils: Support unicode in signatures
Currently if a signature name has a non-ascii unicode character in it, the thread will fail to load because a UnicodeEncodeError. This patch fixes that by converting the str into unicode.
Diffstat (limited to 'alot/db/utils.py')
-rw-r--r--alot/db/utils.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/alot/db/utils.py b/alot/db/utils.py
index ac91098a..06cb021e 100644
--- a/alot/db/utils.py
+++ b/alot/db/utils.py
@@ -39,25 +39,28 @@ def add_signature_headers(mail, sigs, error_msg):
:param error_msg: `str` containing an error message, the empty
string indicating no error
'''
- sig_from = ''
+ sig_from = u''
+
+ if isinstance(error_msg, str):
+ error_msg = error_msg.decode('utf-8')
if len(sigs) == 0:
- error_msg = error_msg or 'no signature found'
+ error_msg = error_msg or u'no signature found'
else:
try:
key = crypto.get_key(sigs[0].fpr)
for uid in key.uids:
if crypto.check_uid_validity(key, uid.email):
- sig_from = uid.uid
+ sig_from = uid.uid.decode('utf-8')
uid_trusted = True
break
else:
# No trusted uid found, we did not break but drop from the
# for loop.
uid_trusted = False
- sig_from = key.uids[0].uid
+ sig_from = key.uids[0].uid.decode('utf-8')
except:
- sig_from = sigs[0].fpr
+ sig_from = sigs[0].fpr.decode('utf-8')
uid_trusted = False
mail.add_header(