From 069f681bc61f2191fbb7f651b5efa7af9d4f6d9f Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Tue, 3 Oct 2017 15:05:46 -0700 Subject: [PATCH] email_mirror: Filter out null characters in email bodies. They're rarely useful, usually displayed invisibly in most tools anyway, and this helps make sure the message makes it into Zulip rather than being rejected. --- zerver/lib/email_mirror.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/zerver/lib/email_mirror.py b/zerver/lib/email_mirror.py index 8843c7a2ec..b256f4f107 100644 --- a/zerver/lib/email_mirror.py +++ b/zerver/lib/email_mirror.py @@ -148,6 +148,8 @@ def mark_missed_message_address_as_used(address): def construct_zulip_body(message, realm): # type: (message.Message, Realm) -> Text body = extract_body(message) + # Remove null characters, since Zulip will reject + body = body.replace("\x00", "") body = filter_footer(body) body += extract_and_upload_attachments(message, realm) if not body: