diff --git a/django/core/mail.py b/django/core/mail.py
index b607573..9b59cfb 100644
a
|
b
|
class BadHeaderError(ValueError):
|
71 | 71 | |
72 | 72 | def forbid_multi_line_headers(name, val): |
73 | 73 | """Forbids multi-line headers, to prevent header injection.""" |
74 | | if '\n' in val or '\r' in val: |
75 | | raise BadHeaderError("Header values can't contain newlines (got %r for header %r)" % (val, name)) |
76 | 74 | try: |
77 | 75 | val = force_unicode(val).encode('ascii') |
78 | 76 | except UnicodeEncodeError: |
… |
… |
def forbid_multi_line_headers(name, val):
|
85 | 83 | val = ', '.join(result) |
86 | 84 | else: |
87 | 85 | val = Header(force_unicode(val), settings.DEFAULT_CHARSET) |
| 86 | if '\n' in val or '\r' in val: |
| 87 | raise BadHeaderError("Header values can't contain newlines (got %r for header %r)" % (val, name)) |
88 | 88 | return name, val |
89 | 89 | |
90 | 90 | class SafeMIMEText(MIMEText): |