summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2018-02-26 09:59:07 -0800
committerDylan Baker <dylan@pnwbakers.com>2018-03-01 10:34:56 -0800
commitf60afac61959b9fe3bf7412e9a72f0db6b70f3b5 (patch)
tree331295dec6a4f35bdce427d989ffd2f95eb90526
parent427fef2fdb4a13efd940e4ce2877332eeacb31e2 (diff)
fix sending encrypted messages in py3k
-rw-r--r--alot/db/envelope.py8
-rw-r--r--alot/helper.py2
2 files changed, 5 insertions, 5 deletions
diff --git a/alot/db/envelope.py b/alot/db/envelope.py
index a539414a..b88cf71e 100644
--- a/alot/db/envelope.py
+++ b/alot/db/envelope.py
@@ -230,12 +230,12 @@ class Envelope(object):
unencrypted_msg = inner_msg
if self.encrypt:
- plaintext = helper.email_as_string(unencrypted_msg)
+ plaintext = helper.email_as_bytes(unencrypted_msg)
logging.debug('encrypting plaintext: %s', plaintext)
try:
- encrypted_str = crypto.encrypt(plaintext,
- self.encrypt_keys.values())
+ encrypted_str = crypto.encrypt(
+ plaintext, list(self.encrypt_keys.values()))
except gpg.errors.GPGMEError as e:
raise GPGProblem(str(e), code=GPGCode.KEY_CANNOT_ENCRYPT)
@@ -248,7 +248,7 @@ class Envelope(object):
_encoder=encode_7or8bit)
encryption_mime.set_charset('us-ascii')
- encrypted_mime = MIMEApplication(_data=encrypted_str,
+ encrypted_mime = MIMEApplication(_data=encrypted_str.decode('ascii'),
_subtype='octet-stream',
_encoder=encode_7or8bit)
encrypted_mime.set_charset('us-ascii')
diff --git a/alot/helper.py b/alot/helper.py
index 368a3e46..ba41986e 100644
--- a/alot/helper.py
+++ b/alot/helper.py
@@ -656,7 +656,7 @@ def email_as_bytes(mail):
# If we get here and the assert triggers it means that different
# parts of the email are encoded differently. I don't think we're
# likely to see that, but it's possible
- assert {'utf-8', 'ascii'}.issuperset(charsets), 'This needs different handling.'
+ assert {'utf-8', 'ascii', 'us-ascii'}.issuperset(charsets), charsets
charset = 'utf-8' # It's a strict super-set
else:
charset = 'utf-8'