summaryrefslogtreecommitdiff
path: root/src/leap
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap')
-rw-r--r--src/leap/mx/mail_receiver.py20
1 files changed, 5 insertions, 15 deletions
diff --git a/src/leap/mx/mail_receiver.py b/src/leap/mx/mail_receiver.py
index 7836ab2..3561d33 100644
--- a/src/leap/mx/mail_receiver.py
+++ b/src/leap/mx/mail_receiver.py
@@ -27,18 +27,12 @@ import json
import email.utils
import socket
-try:
- import cchardet as chardet
-except ImportError:
- import chardet
-
from email import message_from_string
from twisted.application.service import Service
from twisted.internet import inotify, defer, task
from twisted.python import filepath, log
-from leap.common.mail import get_email_charset
from leap.soledad.common.crypto import (
EncryptionSchemes,
ENC_JSON_KEY,
@@ -117,12 +111,6 @@ class MailReceiver(Service):
# find message's encoding
message_as_string = message.as_string()
- encoding = get_email_charset(
- message_as_string.decode("utf8", "replace"),
- default=None)
- if encoding is None:
- result = chardet.detect(message_as_string)
- encoding = result["encoding"]
doc = CouchDocument(doc_id=str(pyuuid.uuid4()))
@@ -132,7 +120,8 @@ class MailReceiver(Service):
doc.content = {
self.INCOMING_KEY: True,
ENC_SCHEME_KEY: EncryptionSchemes.NONE,
- ENC_JSON_KEY: json.dumps(data, encoding=encoding)
+ ENC_JSON_KEY: json.dumps(data,
+ ensure_ascii=False)
}
return doc
@@ -142,7 +131,8 @@ class MailReceiver(Service):
key = gpg.list_keys().pop()
# We don't care about the actual address, so we use a
# dummy one, we just care about the import of the pubkey
- openpgp_key = openpgp._build_key_from_gpg("dummy@mail.com", key, pubkey)
+ openpgp_key = openpgp._build_key_from_gpg("dummy@mail.com",
+ key, pubkey)
# add X-Leap-Provenance header if message is not encrypted
if message.get_content_type() != 'multipart/encrypted' and \
@@ -157,7 +147,7 @@ class MailReceiver(Service):
self.INCOMING_KEY: True,
ENC_SCHEME_KEY: EncryptionSchemes.PUBKEY,
ENC_JSON_KEY: str(gpg.encrypt(
- json.dumps(data, encoding=encoding),
+ json.dumps(data, ensure_ascii=False),
openpgp_key.fingerprint,
symmetric=False))
}