From d434bf4bb45b20ca1dbfefd55c4918cd46f8bd22 Mon Sep 17 00:00:00 2001 From: Jessica McKellar Date: Mon, 23 Sep 2013 10:25:59 -0400 Subject: [PATCH] email mirror: use a message part's specific charset rather than the message charset. The overall message charset may be null or not match the part's charset. Even though it's unclear from the documentation, experimentally using the charset for a message part seems to give you the charset even for non-multipart emails. (imported from commit 0e1d23073f4c53041f9760e66a6635f8a94893d1) --- zerver/management/commands/email-mirror.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/zerver/management/commands/email-mirror.py b/zerver/management/commands/email-mirror.py index a4970c277f..9c19bde10b 100755 --- a/zerver/management/commands/email-mirror.py +++ b/zerver/management/commands/email-mirror.py @@ -132,13 +132,13 @@ def valid_stream(stream_name, token): return False def get_message_part_by_type(message, content_type): - charset = message.get_content_charset() + charsets = message.get_charsets() - for part in message.walk(): + for idx, part in enumerate(message.walk()): if part.get_content_type() == content_type: content = part.get_payload(decode=True) - if charset: - content = content.decode(charset) + if charsets[idx]: + content = content.decode(charsets[idx]) return content def extract_body(message):