summaryrefslogtreecommitdiffstats
path: root/wallace
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2013-05-03 14:38:13 +0200
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2013-05-03 18:00:22 +0200
commit3c760fc298ca610e81119b0427b5b5ecb8fd116f (patch)
tree83a29c8e1741d17a5325828f9b0a1c8a7fae539a /wallace
parent9d8fd99811f9c70af7baa74a1b06968b2908c0dd (diff)
downloadpykolab-3c760fc298ca610e81119b0427b5b5ecb8fd116f.tar.gz
Replace the blob null bytes we're getting (#1627, #1631)
Diffstat (limited to 'wallace')
-rw-r--r--wallace/modules.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/wallace/modules.py b/wallace/modules.py
index c96c924..d256bdb 100644
--- a/wallace/modules.py
+++ b/wallace/modules.py
@@ -251,8 +251,20 @@ X-Wallace-Result: REJECT
def cb_action_ACCEPT(module, filepath):
log.info(_("Accepting message in %s (by module %s)") % (filepath, module))
- _message = json.load(open(filepath, 'r'))
- message = message_from_string(_message['data'])
+ try:
+ _message = json.load(open(filepath, 'r'))
+ log.debug(_(u"Message JSON loaded: %r") % (_message), level=9)
+ except Exception, errmsg:
+ log.error(_("Error loading message: %r") % (errmsg))
+ return
+
+ try:
+ message = message_from_string(str(_message['data']).replace('\x00',''))
+ except Exception, errmsg:
+ log.error(_("Error parsing message: %r") % (errmsg))
+ return
+
+ log.debug(_("Accepting message in: %r") %(filepath), level=8)
sender = _message['from']
recipients = _message['to']
@@ -271,8 +283,7 @@ def cb_action_ACCEPT(module, filepath):
# come from (TODO)
# - Third, a character return is inserted somewhere. It
# divides the body from the headers - and we don't like (TODO)
- #unicode(message.as_string()).replace('\0', '').lstrip()
- message.as_string().encode('utf-8').replace('\0','').lstrip()
+ message.as_string()
)
except smtplib.SMTPDataError, errmsg: