diff --git a/ietf/ipr/mail.py b/ietf/ipr/mail.py index 93b8ff9d8..1f4497e7e 100644 --- a/ietf/ipr/mail.py +++ b/ietf/ipr/mail.py @@ -1,4 +1,8 @@ # Copyright The IETF Trust 2014-2019, All Rights Reserved +# -*- coding: utf-8 -*- + + +from __future__ import absolute_import, print_function, unicode_literals import base64 import email @@ -9,7 +13,7 @@ import pytz import re from django.template.loader import render_to_string -from django.utils.encoding import force_text +from django.utils.encoding import force_text, force_str import debug # pyflakes:ignore @@ -171,7 +175,7 @@ def process_response_email(msg): a matching value in the reply_to field, associated to an IPR disclosure through IprEvent. Create a Message object for the incoming message and associate it to the original message via new IprEvent""" - message = email.message_from_string(msg) + message = email.message_from_string(force_str(msg)) to = message.get('To') # exit if this isn't a response we're interested in (with plus addressing) diff --git a/ietf/message/utils.py b/ietf/message/utils.py index 8c0c6934a..1460fed62 100644 --- a/ietf/message/utils.py +++ b/ietf/message/utils.py @@ -1,13 +1,20 @@ # Copyright The IETF Trust 2012-2019, All Rights Reserved +# -*- coding: utf-8 -*- + + +from __future__ import absolute_import, print_function, unicode_literals + import re, datetime, email -from ietf.utils.mail import send_mail_text, send_mail_mime +from django.utils.encoding import force_str + +from ietf.utils.mail import send_mail_text, send_mail_mime, get_payload from ietf.message.models import Message first_dot_on_line_re = re.compile(r'^\.', re.MULTILINE) def infer_message(s): - parsed = email.message_from_string(s) + parsed = email.message_from_string(force_str(s)) m = Message() m.subject = parsed.get("Subject", "") @@ -16,7 +23,7 @@ def infer_message(s): m.cc = parsed.get("Cc", "") m.bcc = parsed.get("Bcc", "") m.reply_to = parsed.get("Reply-To", "") - m.body = parsed.get_payload() + m.body = get_payload(parsed) return m @@ -41,7 +48,7 @@ def send_scheduled_message_from_send_queue(send_queue): # make body a real message so we can parse it body = ("MIME-Version: 1.0\r\nContent-Type: %s\r\n" % message.content_type) + body - msg = email.message_from_string(body) + msg = email.message_from_string(force_str(body)) send_mail_mime(None, message.to, message.frm, message.subject, msg, cc=message.cc, bcc=message.bcc) diff --git a/ietf/submit/mail.py b/ietf/submit/mail.py index 3ffb3769a..1014ea6ea 100644 --- a/ietf/submit/mail.py +++ b/ietf/submit/mail.py @@ -1,4 +1,8 @@ # Copyright The IETF Trust 2013-2019, All Rights Reserved +# -*- coding: utf-8 -*- + + +from __future__ import absolute_import, print_function, unicode_literals import re import email @@ -12,7 +16,7 @@ from django.urls import reverse as urlreverse from django.core.validators import ValidationError from django.contrib.sites.models import Site from django.template.loader import render_to_string -from django.utils.encoding import force_text +from django.utils.encoding import force_text, force_str import debug # pyflakes:ignore @@ -186,7 +190,7 @@ def process_response_email(msg): a matching value in the reply_to field, associated to a submission. Create a Message object for the incoming message and associate it to the original message via new SubmissionEvent""" - message = email.message_from_string(msg) + message = email.message_from_string(force_str(msg)) to = message.get('To') # exit if this isn't a response we're interested in (with plus addressing)