Merge pull request #14558 from Snuffleupagus/getFilenameFromContentDispositionHeader-TextDecoder

Remove the UTF-8 fallback, when `TextDecoder` is missing, from the Content-Disposition parser
This commit is contained in:
Tim van der Meij 2022-02-13 14:02:50 +01:00 committed by GitHub
commit 7ee531d918
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,7 +19,6 @@ import { stringToBytes } from "../shared/util.js";
// https://github.com/Rob--W/open-in-browser/blob/7e2e35a38b8b4e981b11da7b2f01df0149049e92/extension/content-disposition.js
// with the following changes:
// - Modified to conform to PDF.js's coding style.
// - Support UTF-8 decoding when TextDecoder is unsupported.
// - Move return to the end of the function to prevent Babel from dropping the
// function declarations.
@ -92,14 +91,6 @@ function getFilenameFromContentDispositionHeader(contentDisposition) {
needsEncodingFixup = false;
} catch (e) {
// TextDecoder constructor threw - unrecognized encoding.
// Or TextDecoder API is not available (in IE / Edge).
if (/^utf-?8$/i.test(encoding)) {
// UTF-8 is commonly used, try to support it in another way:
try {
value = decodeURIComponent(escape(value));
needsEncodingFixup = false;
} catch (err) {}
}
}
}
return value;