diff --git a/django/core/mail.py b/django/core/mail.py
index 6a45b46..677d59f 100644
a
|
b
|
from email.MIMEText import MIMEText
|
13 | 13 | from email.MIMEMultipart import MIMEMultipart |
14 | 14 | from email.MIMEBase import MIMEBase |
15 | 15 | from email.Header import Header |
16 | | from email.Utils import formatdate, parseaddr, formataddr |
| 16 | from email.Utils import formatdate, parseaddr, formataddr, getaddresses |
17 | 17 | |
18 | 18 | from django.conf import settings |
19 | 19 | from django.utils.encoding import smart_str, force_unicode |
… |
… |
def forbid_multi_line_headers(name, val):
|
79 | 79 | except UnicodeEncodeError: |
80 | 80 | if name.lower() in ('to', 'from', 'cc'): |
81 | 81 | result = [] |
82 | | for item in val.split(', '): |
83 | | nm, addr = parseaddr(item) |
| 82 | for nm,addr in getaddresses( (val,) ): |
84 | 83 | nm = str(Header(nm, settings.DEFAULT_CHARSET)) |
85 | 84 | result.append(formataddr((nm, str(addr)))) |
86 | 85 | val = ', '.join(result) |
diff --git a/tests/regressiontests/mail/tests.py b/tests/regressiontests/mail/tests.py
index 40e2f76..a58c9bd 100644
a
|
b
|
BadHeaderError: Header values can't contain newlines (got u'Subject\nInjection T
|
95 | 95 | >>> message['From'] |
96 | 96 | 'from@example.com' |
97 | 97 | |
| 98 | # |
| 99 | |
| 100 | >>> email = EmailMessage('Subject', 'Content', 'from@example.com', ['"Sürname, Firstname" <to@example.com>','other@example.com']) |
| 101 | >>> email.message()['To'] |
| 102 | '=?utf-8?q?S=C3=BCrname=2C_Firstname?= <to@example.com>, other@example.com' |
| 103 | |
98 | 104 | """ |