summaryrefslogtreecommitdiff
path: root/mail/src/leap
diff options
context:
space:
mode:
authorTomás Touceda <chiiph@leap.se>2014-01-22 14:00:29 -0300
committerTomás Touceda <chiiph@leap.se>2014-01-22 14:00:29 -0300
commitccab7ac16dd40f822e2beafad4775dca90dd51b5 (patch)
tree6ea71e5639e1ca4b9e02ad54be31e7928eec102f /mail/src/leap
parente844ac826b5e97cea2dd7c4bf240574f2cc57eb6 (diff)
parente99af33d1cefe4797f72b4939bf775348df2586e (diff)
Merge remote-tracking branch 'refs/remotes/drebs/bug/5014_fix-attachment-processing-when-signing' into develop
Diffstat (limited to 'mail/src/leap')
-rw-r--r--mail/src/leap/mail/smtp/gateway.py13
-rw-r--r--mail/src/leap/mail/smtp/rfc3156.py28
2 files changed, 28 insertions, 13 deletions
diff --git a/mail/src/leap/mail/smtp/gateway.py b/mail/src/leap/mail/smtp/gateway.py
index bef5c6d..ef398d1 100644
--- a/mail/src/leap/mail/smtp/gateway.py
+++ b/mail/src/leap/mail/smtp/gateway.py
@@ -600,13 +600,16 @@ class EncryptedMessage(object):
self._msg = self._origmsg
return
- # add a nice footer to the outgoing message
from_address = validate_address(self._fromAddress.addrstr)
username, domain = from_address.split('@')
- self.lines.append('--')
- self.lines.append('%s - https://%s/key/%s' %
- (self.FOOTER_STRING, domain, username))
- self.lines.append('')
+
+ # add a nice footer to the outgoing message
+ if self._origmsg.get_content_type() == 'text/plain':
+ self.lines.append('--')
+ self.lines.append('%s - https://%s/key/%s' %
+ (self.FOOTER_STRING, domain, username))
+ self.lines.append('')
+
self._origmsg = self.parseMessage()
# get sender and recipient data
diff --git a/mail/src/leap/mail/smtp/rfc3156.py b/mail/src/leap/mail/smtp/rfc3156.py
index 9739531..2c6d4a7 100644
--- a/mail/src/leap/mail/smtp/rfc3156.py
+++ b/mail/src/leap/mail/smtp/rfc3156.py
@@ -24,6 +24,7 @@ import base64
from abc import ABCMeta, abstractmethod
from StringIO import StringIO
+from twisted.python import log
from email.mime.application import MIMEApplication
from email.mime.multipart import MIMEMultipart
from email import errors
@@ -145,14 +146,25 @@ def encode_base64(msg):
:param msg: The non-multipart message to be encoded.
:type msg: email.message.Message
"""
- orig = msg.get_payload()
- encdata = _bencode(orig)
- msg.set_payload(encdata)
- # replace or set the Content-Transfer-Encoding header.
- try:
- msg.replace_header('Content-Transfer-Encoding', 'base64')
- except KeyError:
- msg['Content-Transfer-Encoding'] = 'base64'
+ encoding = msg.get('Content-Transfer-Encoding', None)
+ # XXX Python's email module can only decode quoted-printable, base64 and
+ # uuencoded data, so we might have to implement other decoding schemes in
+ # order to support RFC 3156 properly and correctly calculate signatures
+ # for multipart attachments (eg. 7bit or 8bit encoded attachments). For
+ # now, if content is already encoded as base64 or if it is encoded with
+ # some unknown encoding, we just pass.
+ if encoding is None or encoding.lower() in ['quoted-printable',
+ 'x-uuencode', 'uue', 'x-uue']:
+ orig = msg.get_payload(decode=True)
+ encdata = _bencode(orig)
+ msg.set_payload(encdata)
+ # replace or set the Content-Transfer-Encoding header.
+ try:
+ msg.replace_header('Content-Transfer-Encoding', 'base64')
+ except KeyError:
+ msg['Content-Transfer-Encoding'] = 'base64'
+ elif encoding is not 'base64':
+ log.err('Unknown content-transfer-encoding: %s' % encoding)
def encode_base64_rec(msg):