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'):
|
||||
# We use the unsafe variant of the filename as we sanitize it via
|
||||
# os.path.basename later.
|
||||
filename = rfc6266.parse_headers(
|
||||
bytes(reply.rawHeader('Content-Disposition'))).filename_unsafe
|
||||
try:
|
||||
content_disposition = rfc6266.parse_headers(
|
||||
bytes(reply.rawHeader('Content-Disposition')))
|
||||
filename = content_disposition.filename_unsafe
|
||||
except UnicodeDecodeError:
|
||||
filename = None
|
||||
else:
|
||||
filename = None
|
||||
# Then try to get filename from url
|
||||
|
Loading…
Reference in New Issue
Block a user