Skip to content

Commit 27e0a62

Browse files
committed
Implementing a slightly tweaked version of Glen and TonyH's fix for mangled content part separators in multiplart messages.
- Legacy-Id: 2649
1 parent 5d5b88a commit 27e0a62

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

ietf/announcements/send_scheduled.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,16 @@ def send_scheduled_announcement(announcement):
1313
if announcement.replyto:
1414
extra['Reply-To'] = announcement.replyto
1515

16-
content_type = announcement.content_type.lower()
17-
if not content_type or 'text/plain' in content_type:
16+
# announcement.content_type can contain a case-sensitive parts separator,
17+
# so we need to keep it as is, not lowercased, but we want a lowercased
18+
# version for the coming comparisons.
19+
content_type_lowercase = announcement.content_type
20+
if not content_type or 'text/plain' in content_type_lowercase:
1821
send_mail_text(None, announcement.to_val, announcement.from_val, announcement.subject,
1922
body, cc=announcement.cc_val, bcc=announcement.bcc_val)
20-
elif 'multipart' in content_type:
21-
# make body a real message so we can parse it
22-
body = ("MIME-Version: 1.0\r\nContent-Type: %s\r\n" % content_type) + body
23+
elif 'multipart/' in content_type_lowercase:
24+
# make body a real message so we can parse it.
25+
body = ("MIME-Version: 1.0\r\nContent-Type: %s\r\n" % announcement.content_type) + body
2326

2427
msg = email.message_from_string(body.encode("utf-8"))
2528
send_mail_mime(None, announcement.to_val, announcement.from_val, announcement.subject,

0 commit comments

Comments
 (0)