﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
21620	HttpResponseBase._convert_to_charset STILL complains about newline it inserted itself	poly	nobody	"As reported in [#20889], a header that is so long will be splitted by email.header.Header into several lines. And tim fixed it [https://github.com/django/django/commit/6dca603abb0eb164ba87657caf5cc65bca449719#diff-eeebc8cb56240caf13a9952431189fefR164 here].[[BR]]
However, when the length of the header exceeds certain limit, email.header.Header still inserts newlines, which raises the great BadHeaderError.
[[BR]]
FYI:

{{{
# coding=utf-8
from django.http import HttpResponse
h = HttpResponse()
f = '\xe6\x88\x91\xe6\x88\x91\xe6\x88\x91\xe6\x88\x91\xe6\x88\x91\xe6\x88\x91\xe6\x88\x91\xe6\x88\x91'.decode('utf-8')
h['Content-Disposition'] = u'attachment; filename=""%s""' % f
}}}
This snippet works when tim's patch is applied, but the next doesn't

{{{
# coding=utf-8
from django.http import HttpResponse
h = HttpResponse()
f = '\xe6\x88\x91\xe6\x88\x91\xe6\x88\x91\xe6\x88\x91\xe6\x88\x91\xe6\x88\x91\xe6\x88\x91\xe6\x88\x91\xe6\x88\x91'.decode('utf-8')
h['Content-Disposition'] = u'attachment; filename=""%s""' % f
}}}
As you can see, the only difference is that the second one has a longer header value.
[[BR]]
Also, I'm wondering why we need to encode those headers in the mime way, since most browsers don't support them(at least chrome), why can't we just encode them in latin1 like what flask does.
Thanks for your time."	Bug	closed	HTTP handling	1.6	Normal	duplicate			Unreviewed	0	0	0	0	0	0
