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.
This commit is contained in:
parent
05e835684d
commit
ef9ddb2d5f
@ -39,14 +39,15 @@ def parse_content_disposition(reply):
|
|||||||
"""
|
"""
|
||||||
is_inline = True
|
is_inline = True
|
||||||
filename = None
|
filename = None
|
||||||
|
content_disposition_header = 'Content-Disposition'.encode('iso-8859-1')
|
||||||
# First check if the Content-Disposition header has a filename
|
# First check if the Content-Disposition header has a filename
|
||||||
# attribute.
|
# 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
|
# We use the unsafe variant of the filename as we sanitize it via
|
||||||
# os.path.basename later.
|
# os.path.basename later.
|
||||||
try:
|
try:
|
||||||
content_disposition = rfc6266.parse_headers(
|
content_disposition = rfc6266.parse_headers(
|
||||||
bytes(reply.rawHeader('Content-Disposition')))
|
bytes(reply.rawHeader(content_disposition_header)))
|
||||||
filename = content_disposition.filename()
|
filename = content_disposition.filename()
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
log.misc.exception("Error while decoding filename")
|
log.misc.exception("Error while decoding filename")
|
||||||
|
Loading…
Reference in New Issue
Block a user