Don't crash on Content-Disposition with wrong enc.
When declaring UTF-8 but encoding RFC2231 ISO-8859-1, rfc2259 raises an UnicodeDecodeError. Test case: http://greenbytes.de/tech/tc2231/#attwithfn2231iso-bad
This commit is contained in:
parent
7690e918a2
commit
3c9b4369cd
@ -344,8 +344,12 @@ class DownloadManager(QObject):
|
|||||||
if reply.hasRawHeader('Content-Disposition'):
|
if reply.hasRawHeader('Content-Disposition'):
|
||||||
# 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.
|
||||||
filename = rfc6266.parse_headers(
|
try:
|
||||||
bytes(reply.rawHeader('Content-Disposition'))).filename_unsafe
|
content_disposition = rfc6266.parse_headers(
|
||||||
|
bytes(reply.rawHeader('Content-Disposition')))
|
||||||
|
filename = content_disposition.filename_unsafe
|
||||||
|
except UnicodeDecodeError:
|
||||||
|
filename = None
|
||||||
else:
|
else:
|
||||||
filename = None
|
filename = None
|
||||||
# Then try to get filename from url
|
# Then try to get filename from url
|
||||||
|
Loading…
Reference in New Issue
Block a user