From 786b339b96c6e76c19376181e6e083ed94f7b481 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Thu, 13 Jul 2017 22:19:49 -0700 Subject: [PATCH] email_mirror: Fix exception for emails with no valid content type. If a broken email shows up with no text or email content-type, we were attempting to return an undefined variable. --- zerver/lib/email_mirror.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/zerver/lib/email_mirror.py b/zerver/lib/email_mirror.py index 4976a2bc50..e979efd397 100644 --- a/zerver/lib/email_mirror.py +++ b/zerver/lib/email_mirror.py @@ -215,8 +215,7 @@ def get_message_part_by_type(message, content_type): content = part.get_payload(decode=True) assert isinstance(content, binary_type) if charsets[idx]: - text = content.decode(charsets[idx], errors="ignore") - return text + return content.decode(charsets[idx], errors="ignore") return None def extract_body(message):