mirror of https://github.com/django/django.git
Fixed #13259 -- Ensure that multiple calls to message() don't corrupt any extra message headers. Thanks to canburak for the report, and Andi Albrecht for the fix.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12901 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
271bcda04a
commit
db5be42c12
|
@ -143,7 +143,7 @@ class EmailMessage(object):
|
|||
self.content_subtype, encoding)
|
||||
msg = self._create_message(msg)
|
||||
msg['Subject'] = self.subject
|
||||
msg['From'] = self.extra_headers.pop('From', self.from_email)
|
||||
msg['From'] = self.extra_headers.get('From', self.from_email)
|
||||
msg['To'] = ', '.join(self.to)
|
||||
|
||||
# Email header names are case-insensitive (RFC 2045), so we have to
|
||||
|
@ -154,6 +154,8 @@ class EmailMessage(object):
|
|||
if 'message-id' not in header_names:
|
||||
msg['Message-ID'] = make_msgid()
|
||||
for name, value in self.extra_headers.items():
|
||||
if name.lower() == 'from': # From is already handled
|
||||
continue
|
||||
msg[name] = value
|
||||
return msg
|
||||
|
||||
|
|
|
@ -101,6 +101,16 @@ BadHeaderError: Header values can't contain newlines (got u'Subject\nInjection T
|
|||
>>> message['From']
|
||||
'from@example.com'
|
||||
|
||||
# Regression for #13259 - Make sure that headers are not changed
|
||||
# when calling EmailMessage.message()
|
||||
>>> email = EmailMessage('Subject', 'Content', 'bounce@example.com', ['to@example.com'], headers={'From': 'from@example.com'})
|
||||
>>> message = email.message()
|
||||
>>> message['From']
|
||||
'from@example.com'
|
||||
>>> message = email.message()
|
||||
>>> message['From']
|
||||
'from@example.com'
|
||||
|
||||
# Regression for #11144 - When a to/from/cc header contains unicode,
|
||||
# make sure the email addresses are parsed correctly (especially
|
||||
# with regards to commas)
|
||||
|
|
Loading…
Reference in New Issue