From ef9ddb2d5fcda6851d97938b9c9f5595de97fcd7 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 18 Dec 2014 23:24:50 +0100 Subject: [PATCH] Encode Content-Disposition header name properly. PyQt <= 5.3 accepted a Python string containing only latin1 chars as argument for a QByteArray. This is deprecated in 5.4 and will be removed in 5.5 so we should encode it by hand here. --- qutebrowser/browser/http.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/qutebrowser/browser/http.py b/qutebrowser/browser/http.py index ebf6722a5..c5d52c4bc 100644 --- a/qutebrowser/browser/http.py +++ b/qutebrowser/browser/http.py @@ -39,14 +39,15 @@ def parse_content_disposition(reply): """ is_inline = True filename = None + content_disposition_header = 'Content-Disposition'.encode('iso-8859-1') # First check if the Content-Disposition header has a filename # attribute. - if reply.hasRawHeader('Content-Disposition'): + if reply.hasRawHeader(content_disposition_header): # We use the unsafe variant of the filename as we sanitize it via # os.path.basename later. try: content_disposition = rfc6266.parse_headers( - bytes(reply.rawHeader('Content-Disposition'))) + bytes(reply.rawHeader(content_disposition_header))) filename = content_disposition.filename() except UnicodeDecodeError: log.misc.exception("Error while decoding filename")