diff options
author | Ruben Pollan <meskio@sindominio.net> | 2017-08-15 18:35:48 +0200 |
---|---|---|
committer | Kali Kaneko <kali@leap.se> | 2017-08-15 16:59:17 -0400 |
commit | 0ec7027662b6fda1c9969846e6a937e9f98cc7b7 (patch) | |
tree | e4bab736c5bade9e07310a78484777f4697e37aa /src | |
parent | 8cabb28ee22131934c5cc59e96019771801b7f6d (diff) |
[bug] encode pgp/mime parts as 7bit encoding
We were encoding some parts as base64 and others with our manual
encoders. Let's not do base64 and use the email standard library
encoders instead.
- Resolves: #8957
Diffstat (limited to 'src')
-rw-r--r-- | src/leap/bitmask/mail/outgoing/service.py | 3 | ||||
-rw-r--r-- | src/leap/bitmask/mail/rfc3156.py | 9 |
2 files changed, 8 insertions, 4 deletions
diff --git a/src/leap/bitmask/mail/outgoing/service.py b/src/leap/bitmask/mail/outgoing/service.py index a3b8d005..86fb63c2 100644 --- a/src/leap/bitmask/mail/outgoing/service.py +++ b/src/leap/bitmask/mail/outgoing/service.py @@ -26,6 +26,7 @@ import re from StringIO import StringIO from copy import deepcopy from email.parser import Parser +from email.encoders import encode_7or8bit from email.mime.application import MIMEApplication from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText @@ -385,7 +386,7 @@ class OutgoingMail(object): def create_encrypted_message(res): newmsg, encstr = res encmsg = MIMEApplication( - encstr, _subtype='octet-stream', _encoder=lambda x: x) + encstr, _subtype='octet-stream', _encoder=encode_7or8bit) encmsg.add_header('content-disposition', 'attachment', filename='msg.asc') # create meta message diff --git a/src/leap/bitmask/mail/rfc3156.py b/src/leap/bitmask/mail/rfc3156.py index cb592689..7f719f63 100644 --- a/src/leap/bitmask/mail/rfc3156.py +++ b/src/leap/bitmask/mail/rfc3156.py @@ -24,6 +24,7 @@ from StringIO import StringIO from twisted.logger import Logger +from email.encoders import encode_7or8bit from email.mime.application import MIMEApplication from email.mime.multipart import MIMEMultipart from email import errors @@ -361,7 +362,8 @@ class PGPEncrypted(MIMEApplication): def __init__(self, version=1): data = "Version: %d" % version - MIMEApplication.__init__(self, data, 'pgp-encrypted') + MIMEApplication.__init__(self, data, 'pgp-encrypted', + _encoder=encode_7or8bit) class PGPSignature(MIMEApplication): @@ -375,7 +377,7 @@ class PGPSignature(MIMEApplication): """ def __init__(self, _data, name='signature.asc'): MIMEApplication.__init__(self, _data, 'pgp-signature', - _encoder=lambda x: x, name=name) + _encoder=encode_7or8bit, name=name) self.add_header('Content-Description', 'OpenPGP Digital Signature') @@ -390,4 +392,5 @@ class PGPKeys(MIMEApplication): """ def __init__(self, _data): - MIMEApplication.__init__(self, _data, 'pgp-keys') + MIMEApplication.__init__(self, _data, 'pgp-keys', + _encoder=encode_7or8bit) |