From 27e0a62b09b4ebde534acf10d658f0ce76e3d288 Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Tue, 9 Nov 2010 08:20:27 +0000 Subject: [PATCH] Implementing a slightly tweaked version of Glen and TonyH's fix for mangled content part separators in multiplart messages. - Legacy-Id: 2649 --- ietf/announcements/send_scheduled.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ietf/announcements/send_scheduled.py b/ietf/announcements/send_scheduled.py index a2fe2a8ac..f42f2f5a4 100644 --- a/ietf/announcements/send_scheduled.py +++ b/ietf/announcements/send_scheduled.py @@ -13,13 +13,16 @@ def send_scheduled_announcement(announcement): if announcement.replyto: extra['Reply-To'] = announcement.replyto - content_type = announcement.content_type.lower() - if not content_type or 'text/plain' in content_type: + # announcement.content_type can contain a case-sensitive parts separator, + # so we need to keep it as is, not lowercased, but we want a lowercased + # version for the coming comparisons. + content_type_lowercase = announcement.content_type + if not content_type or 'text/plain' in content_type_lowercase: send_mail_text(None, announcement.to_val, announcement.from_val, announcement.subject, body, cc=announcement.cc_val, bcc=announcement.bcc_val) - elif 'multipart' in content_type: - # make body a real message so we can parse it - body = ("MIME-Version: 1.0\r\nContent-Type: %s\r\n" % content_type) + body + elif 'multipart/' in content_type_lowercase: + # make body a real message so we can parse it. + body = ("MIME-Version: 1.0\r\nContent-Type: %s\r\n" % announcement.content_type) + body msg = email.message_from_string(body.encode("utf-8")) send_mail_mime(None, announcement.to_val, announcement.from_val, announcement.subject,