From 0e4e79169ba9bc428a0aba323ab3b84576c58a5c Mon Sep 17 00:00:00 2001 From: Rob Wu Date: Sun, 3 Jun 2018 16:16:16 +0200 Subject: [PATCH] Fall back to ISO-8859-1 in content_disposition.js Updates content_disposition.js to include https://github.com/Rob--W/open-in-browser/commit/9b789d9b3bb8e7992635627341a88dcf19f2dc42 --- src/display/content_disposition.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/display/content_disposition.js b/src/display/content_disposition.js index af180181e..0dec00c88 100644 --- a/src/display/content_disposition.js +++ b/src/display/content_disposition.js @@ -107,7 +107,11 @@ function getFilenameFromContentDispositionHeader(contentDisposition) { function fixupEncoding(value) { if (needsEncodingFixup && /[\x80-\xff]/.test(value)) { // Maybe multi-byte UTF-8. - return textdecode('utf-8', value); + value = textdecode('utf-8', value); + if (needsEncodingFixup) { + // Try iso-8859-1 encoding. + value = textdecode('iso-8859-1', value); + } } return value; } @@ -209,10 +213,10 @@ function getFilenameFromContentDispositionHeader(contentDisposition) { return textdecode(charset, text); } // else encoding is b or B - base64 (RFC 2047 section 4.1) try { - return atob(text); + text = atob(text); } catch (e) { - return text; } + return textdecode(charset, text); }); }