Skip to content

Commit

Permalink
Fall back to ISO-8859-1 in content_disposition.js
Browse files Browse the repository at this point in the history
Updates content_disposition.js to include
Rob--W/open-in-browser@9b789d9
  • Loading branch information
Rob--W committed Jun 3, 2018
1 parent e8a9624 commit 8f946f6
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/display/content_disposition.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
});
}

Expand Down

0 comments on commit 8f946f6

Please sign in to comment.