Fixed #5778 -- Changed the way we detect if a string is non-ASCII when creating
email headers. This fixes a problem that was showing up on some (but not all) systems. git-svn-id: http://code.djangoproject.com/svn/django/trunk@6551 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
f34935c37f
commit
a0fdd7c7dd
|
@ -73,7 +73,7 @@ class SafeMIMEText(MIMEText):
|
||||||
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)
|
||||||
try:
|
try:
|
||||||
val = str(force_unicode(val))
|
val = force_unicode(val).encode('ascii')
|
||||||
except UnicodeEncodeError:
|
except UnicodeEncodeError:
|
||||||
if name.lower() in ('to', 'from', 'cc'):
|
if name.lower() in ('to', 'from', 'cc'):
|
||||||
result = []
|
result = []
|
||||||
|
@ -92,7 +92,7 @@ class SafeMIMEMultipart(MIMEMultipart):
|
||||||
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)
|
||||||
try:
|
try:
|
||||||
val = str(force_unicode(val))
|
val = force_unicode(val).encode('ascii')
|
||||||
except UnicodeEncodeError:
|
except UnicodeEncodeError:
|
||||||
if name.lower() in ('to', 'from', 'cc'):
|
if name.lower() in ('to', 'from', 'cc'):
|
||||||
result = []
|
result = []
|
||||||
|
|
Loading…
Reference in New Issue