Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #7747: Altered EmailMessage such that messages with long subjec…

…t lines don't use tabs in their continutation sequence. Tabs in subjects cause problems with Outlook and Thunderbird. Thanks to Mark Allison <mark.allison@maplecroft.com> for the report and fix.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@8483 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 0f869f905e7d3a335ea9090fa079baf4b5883ec7 1 parent b35acb3
Russell Keith-Magee freakboy3742 authored
Showing with 14 additions and 0 deletions.
  1. +3 −0  django/core/mail.py
  2. +11 −0 tests/regressiontests/mail/tests.py
3  django/core/mail.py
View
@@ -86,6 +86,9 @@ def forbid_multi_line_headers(name, val):
val = ', '.join(result)
else:
val = Header(val, settings.DEFAULT_CHARSET)
+ else:
+ if name.lower() == 'subject':
+ val = Header(val)
return name, val
class SafeMIMEText(MIMEText):
11 tests/regressiontests/mail/tests.py
View
@@ -10,6 +10,8 @@
>>> email = EmailMessage('Subject', 'Content', 'from@example.com', ['to@example.com'])
>>> message = email.message()
>>> message['Subject']
+<email.header.Header instance...>
+>>> message['Subject'].encode()
'Subject'
>>> message.get_payload()
'Content'
@@ -23,6 +25,8 @@
>>> email = EmailMessage('Subject', 'Content', 'from@example.com', ['to@example.com','other@example.com'])
>>> message = email.message()
>>> message['Subject']
+<email.header.Header instance...>
+>>> message['Subject'].encode()
'Subject'
>>> message.get_payload()
'Content'
@@ -45,4 +49,11 @@
...
BadHeaderError: Header values can't contain newlines (got u'Subject\nInjection Test' for header 'Subject')
+# Test for space continuation character in long (ascii) subject headers (#7747)
+
+>>> email = EmailMessage('Long subject lines that get wrapped should use a space continuation character to get expected behaviour in Outlook and Thunderbird', 'Content', 'from@example.com', ['to@example.com'])
+>>> message = email.message()
+>>> message.as_string()
+'Content-Type: text/plain; charset="utf-8"\nMIME-Version: 1.0\nContent-Transfer-Encoding: quoted-printable\nSubject: Long subject lines that get wrapped should use a space continuation\n character to get expected behaviour in Outlook and Thunderbird\nFrom: from@example.com\nTo: to@example.com\nDate: ...\nMessage-ID: <...>\n\nContent'
+
"""
Please sign in to comment.
Something went wrong with that request. Please try again.