1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #20889 -- Prevented email.Header from inserting newlines

Passed large maxlinelen to email.Header to prevent newlines from being
inserted into value returned by _convert_to_charset

Thanks mjl at laubach.at for the report.
This commit is contained in:
Daniel Boeve
2013-09-06 18:47:08 +00:00
committed by Tim Graham
parent aeed2cf3b2
commit 6dca603abb
2 changed files with 9 additions and 1 deletions

View File

@@ -2,6 +2,7 @@ from __future__ import unicode_literals
import datetime
import time
import sys
from email.header import Header
try:
from urllib.parse import urlparse
@@ -160,7 +161,7 @@ class HttpResponseBase(six.Iterator):
except UnicodeError as e:
if mime_encode:
# Wrapping in str() is a workaround for #12422 under Python 2.
value = str(Header(value, 'utf-8').encode())
value = str(Header(value, 'utf-8', maxlinelen=sys.maxsize).encode())
else:
e.reason += ', HTTP response headers must be in %s format' % charset
raise