mirror of https://github.com/scrapy/scrapy.git
fix: non-UTF-8 content-type headers
This commit is contained in:
parent
b50c032ee9
commit
8acde511a9
|
|
@ -100,11 +100,13 @@ class TextResponse(Response):
|
|||
@memoizemethod_noargs
|
||||
def _headers_encoding(self):
|
||||
content_type = self.headers.get(b"Content-Type", b"")
|
||||
return http_content_type_encoding(to_unicode(content_type))
|
||||
return http_content_type_encoding(to_unicode(content_type, encoding="latin-1"))
|
||||
|
||||
def _body_inferred_encoding(self):
|
||||
if self._cached_benc is None:
|
||||
content_type = to_unicode(self.headers.get(b"Content-Type", b""))
|
||||
content_type = to_unicode(
|
||||
self.headers.get(b"Content-Type", b""), encoding="latin-1"
|
||||
)
|
||||
benc, ubody = html_to_unicode(
|
||||
content_type,
|
||||
self.body,
|
||||
|
|
|
|||
|
|
@ -51,7 +51,9 @@ class ResponseTypes:
|
|||
header"""
|
||||
if content_encoding:
|
||||
return Response
|
||||
mimetype = to_unicode(content_type).split(";")[0].strip().lower()
|
||||
mimetype = (
|
||||
to_unicode(content_type, encoding="latin-1").split(";")[0].strip().lower()
|
||||
)
|
||||
return self.from_mimetype(mimetype)
|
||||
|
||||
def from_content_disposition(self, content_disposition):
|
||||
|
|
|
|||
Loading…
Reference in New Issue