Skip to content

Commit

Permalink
Fixed #6918: Adjusted the test in r12683 to more specifically look fo…
Browse files Browse the repository at this point in the history
…r what it is testing so it doesn't get thrown off by other minor differences in email ouput (hopefully). Also put a docstring back in its place.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@12688 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
kmtracey committed Mar 6, 2010
1 parent bb3d93f commit a2c4ad1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion django/core/mail/message.py
Expand Up @@ -55,8 +55,8 @@ def make_msgid(idstring=None):




def forbid_multi_line_headers(name, val, encoding): def forbid_multi_line_headers(name, val, encoding):
encoding = encoding or settings.DEFAULT_CHARSET
"""Forbids multi-line headers, to prevent header injection.""" """Forbids multi-line headers, to prevent header injection."""
encoding = encoding or settings.DEFAULT_CHARSET
val = force_unicode(val) val = force_unicode(val)
if '\n' in val or '\r' in val: if '\n' in val or '\r' in val:
raise BadHeaderError("Header values can't contain newlines (got %r for header %r)" % (val, name)) raise BadHeaderError("Header values can't contain newlines (got %r for header %r)" % (val, name))
Expand Down
6 changes: 4 additions & 2 deletions tests/regressiontests/mail/tests.py
Expand Up @@ -147,8 +147,10 @@
>>> msg = EmailMultiAlternatives('Subject', text_content, 'from@example.com', ['to@example.com']) >>> msg = EmailMultiAlternatives('Subject', text_content, 'from@example.com', ['to@example.com'])
>>> msg.encoding = 'iso-8859-1' >>> msg.encoding = 'iso-8859-1'
>>> msg.attach_alternative(html_content, "text/html") >>> msg.attach_alternative(html_content, "text/html")
>>> msg.message().as_string() >>> msg.message().get_payload(0).as_string()
'Content-Type: multipart/alternative; boundary="===============...=="\nMIME-Version: 1.0\nSubject: Subject\nFrom: from@example.com\nTo: to@example.com\nDate: ...\nMessage-ID: <...>\n\n--===============...==\nContent-Type: text/plain; charset="iso-8859-1"\nMIME-Version: 1.0\nContent-Transfer-Encoding: quoted-printable\n\nFirstname S=FCrname is a great guy.\n--===============...==\nContent-Type: text/html; charset="iso-8859-1"\nMIME-Version: 1.0\nContent-Transfer-Encoding: quoted-printable\n\n<p>Firstname S=FCrname is a <strong>great</strong> guy.</p>\n--===============...==--' 'Content-Type: text/plain; charset="iso-8859-1"\nMIME-Version: 1.0\nContent-Transfer-Encoding: quoted-printable\n\nFirstname S=FCrname is a great guy.'
>>> msg.message().get_payload(1).as_string()
'Content-Type: text/html; charset="iso-8859-1"\nMIME-Version: 1.0\nContent-Transfer-Encoding: quoted-printable\n\n<p>Firstname S=FCrname is a <strong>great</strong> guy.</p>'
# Handle attachments within an multipart/alternative mail correctly (#9367) # Handle attachments within an multipart/alternative mail correctly (#9367)
# (test is not as precise/clear as it could be w.r.t. email tree structure, # (test is not as precise/clear as it could be w.r.t. email tree structure,
Expand Down

0 comments on commit a2c4ad1

Please sign in to comment.