Ticket #7747: long_email_subject_wrapping_fix_and_test.diff

File long_email_subject_wrapping_fix_and_test.diff, 2.1 KB (added by mark.allison@…, 16 years ago)

updated patch for compatibility with latest code and added test

  • django/django/core/mail.py

     
    8686            val = ', '.join(result)
    8787        else:
    8888            val = Header(val, settings.DEFAULT_CHARSET)
     89    else:
     90        if name.lower() == 'subject':
     91            val = Header(val)
    8992    return name, val
    9093
    9194class SafeMIMEText(MIMEText):
  • django/tests/regressiontests/mail/tests.py

     
    1010>>> email = EmailMessage('Subject', 'Content', 'from@example.com', ['to@example.com'])
    1111>>> message = email.message()
    1212>>> message['Subject']
     13<email.header.Header instance at 0x...>
     14>>> message['Subject'].encode()
    1315'Subject'
    1416>>> message.get_payload()
    1517'Content'
     
    2325>>> email = EmailMessage('Subject', 'Content', 'from@example.com', ['to@example.com','other@example.com'])
    2426>>> message = email.message()
    2527>>> message['Subject']
     28<email.header.Header instance at 0x...>
     29>>> message['Subject'].encode()
    2630'Subject'
    2731>>> message.get_payload()
    2832'Content'
     
    4549    ...
    4650BadHeaderError: Header values can't contain newlines (got u'Subject\nInjection Test' for header 'Subject')
    4751
     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
    4859"""
Back to Top