Ticket #7747: long_email_subject_wrapping_fix_and_test.diff
File long_email_subject_wrapping_fix_and_test.diff, 2.1 KB (added by , 16 years ago) |
---|
-
django/django/core/mail.py
86 86 val = ', '.join(result) 87 87 else: 88 88 val = Header(val, settings.DEFAULT_CHARSET) 89 else: 90 if name.lower() == 'subject': 91 val = Header(val) 89 92 return name, val 90 93 91 94 class SafeMIMEText(MIMEText): -
django/tests/regressiontests/mail/tests.py
10 10 >>> email = EmailMessage('Subject', 'Content', 'from@example.com', ['to@example.com']) 11 11 >>> message = email.message() 12 12 >>> message['Subject'] 13 <email.header.Header instance at 0x...> 14 >>> message['Subject'].encode() 13 15 'Subject' 14 16 >>> message.get_payload() 15 17 'Content' … … 23 25 >>> email = EmailMessage('Subject', 'Content', 'from@example.com', ['to@example.com','other@example.com']) 24 26 >>> message = email.message() 25 27 >>> message['Subject'] 28 <email.header.Header instance at 0x...> 29 >>> message['Subject'].encode() 26 30 'Subject' 27 31 >>> message.get_payload() 28 32 'Content' … … 45 49 ... 46 50 BadHeaderError: Header values can't contain newlines (got u'Subject\nInjection Test' for header 'Subject') 47 51 52 # Test for space continuation character in long (ascii) subject headers 53 54 >>> 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']) 55 >>> message = email.message() 56 >>> message.as_string() 57 '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' 58 48 59 """