Author: russellm
Date: 2008-08-23 08:31:28 -0500 (Sat, 23 Aug 2008)
New Revision: 8483

Modified:
   django/trunk/django/core/mail.py
   django/trunk/tests/regressiontests/mail/tests.py
Log:
Fixed #7747: Altered EmailMessage such that messages with long subject lines 
don't use tabs in their continutation sequence. Tabs in subjects cause problems 
with Outlook and Thunderbird. Thanks to Mark Allison <[EMAIL PROTECTED]> for 
the report and fix.

Modified: django/trunk/django/core/mail.py
===================================================================
--- django/trunk/django/core/mail.py    2008-08-23 13:14:10 UTC (rev 8482)
+++ django/trunk/django/core/mail.py    2008-08-23 13:31:28 UTC (rev 8483)
@@ -86,6 +86,9 @@
             val = ', '.join(result)
         else:
             val = Header(val, settings.DEFAULT_CHARSET)
+    else:
+        if name.lower() == 'subject':
+            val = Header(val)
     return name, val
 
 class SafeMIMEText(MIMEText):

Modified: django/trunk/tests/regressiontests/mail/tests.py
===================================================================
--- django/trunk/tests/regressiontests/mail/tests.py    2008-08-23 13:14:10 UTC 
(rev 8482)
+++ django/trunk/tests/regressiontests/mail/tests.py    2008-08-23 13:31:28 UTC 
(rev 8483)
@@ -10,6 +10,8 @@
 >>> email = EmailMessage('Subject', 'Content', '[EMAIL PROTECTED]', ['[EMAIL 
 >>> PROTECTED]'])
 >>> 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', '[EMAIL PROTECTED]', ['[EMAIL 
 >>> PROTECTED]','[EMAIL PROTECTED]'])
 >>> 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', '[EMAIL PROTECTED]', ['[EMAIL PROTECTED]'])
+>>> 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: [EMAIL PROTECTED]: [EMAIL 
PROTECTED]: ...\nMessage-ID: <...>\n\nContent'
+
 """


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to