Python2/3 compatibility: Added force_str or force_bytes in some places, to ensure the argument right type
- Legacy-Id: 16453
This commit is contained in:
parent
a5e31c3f40
commit
99a7f9c263
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue