diff options
Diffstat (limited to 'deluge/httpdownloader.py')
-rw-r--r-- | deluge/httpdownloader.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/deluge/httpdownloader.py b/deluge/httpdownloader.py index b4acd0784..f0fe09ec0 100644 --- a/deluge/httpdownloader.py +++ b/deluge/httpdownloader.py @@ -151,9 +151,12 @@ class HTTPDownloaderAgent(object): self.filename = new_file_name - cont_type = headers.getRawHeaders(b'content-type')[0].decode() - params = cgi.parse_header(cont_type)[1] - encoding = params.get('charset', None) + cont_type_header = headers.getRawHeaders(b'content-type')[0].decode() + cont_type, params = cgi.parse_header(cont_type_header) + # Only re-ecode text content types. + encoding = None + if cont_type.startswith('text/'): + encoding = params.get('charset', None) response.deliverBody( BodyHandler(response.request, finished, body_length, self, encoding) ) |