diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2018-02-26 09:59:07 -0800 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2018-03-01 10:34:56 -0800 |
commit | f60afac61959b9fe3bf7412e9a72f0db6b70f3b5 (patch) | |
tree | 331295dec6a4f35bdce427d989ffd2f95eb90526 | |
parent | 427fef2fdb4a13efd940e4ce2877332eeacb31e2 (diff) |
fix sending encrypted messages in py3k
-rw-r--r-- | alot/db/envelope.py | 8 | ||||
-rw-r--r-- | alot/helper.py | 2 |
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' |