Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #6299 -- Fixed an indentation error in django/core/mail.py intr…

…oduced in [6987]

git-svn-id: http://code.djangoproject.com/svn/django/trunk@6989 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 5496c50b62da5c9b96ebc0de46db1f3b8a4d52e1 1 parent 1264bcf
@adrianholovaty adrianholovaty authored
Showing with 16 additions and 16 deletions.
  1. +16 −16 django/core/mail.py
View
32 django/core/mail.py
@@ -68,22 +68,22 @@ class BadHeaderError(ValueError):
pass
def forbid_multi_line_headers(name, val):
- "Forbids multi-line headers, to prevent header injection."
- if '\n' in val or '\r' in val:
- raise BadHeaderError, "Header values can't contain newlines (got %r for header %r)" % (val, name)
- try:
- val = force_unicode(val).encode('ascii')
- except UnicodeEncodeError:
- if name.lower() in ('to', 'from', 'cc'):
- result = []
- for item in val.split(', '):
- nm, addr = parseaddr(item)
- nm = str(Header(nm, settings.DEFAULT_CHARSET))
- result.append(formataddr((nm, str(addr))))
- val = ', '.join(result)
- else:
- val = Header(force_unicode(val), settings.DEFAULT_CHARSET)
- return (name, val)
+ "Forbids multi-line headers, to prevent header injection."
+ if '\n' in val or '\r' in val:
+ raise BadHeaderError("Header values can't contain newlines (got %r for header %r)" % (val, name))
+ try:
+ val = force_unicode(val).encode('ascii')
+ except UnicodeEncodeError:
+ if name.lower() in ('to', 'from', 'cc'):
+ result = []
+ for item in val.split(', '):
+ nm, addr = parseaddr(item)
+ nm = str(Header(nm, settings.DEFAULT_CHARSET))
+ result.append(formataddr((nm, str(addr))))
+ val = ', '.join(result)
+ else:
+ val = Header(force_unicode(val), settings.DEFAULT_CHARSET)
+ return name, val
class SafeMIMEText(MIMEText):
def __setitem__(self, name, val):
Please sign in to comment.
Something went wrong with that request. Please try again.