Merge pull request #11582 from Snuffleupagus/Array-fail-on-enumerable-properties
[api-minor] Ensure that the `Array.prototype` doesn't contain any enumerable properties
This commit is contained in:
commit
10be0997a7
@ -117,6 +117,26 @@ var WorkerMessageHandler = {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||||
|
// Fail early, and predictably, rather than having (some) fonts fail to
|
||||||
|
// load/render with slightly cryptic error messages in environments where
|
||||||
|
// the `Array.prototype` has been *incorrectly* extended.
|
||||||
|
//
|
||||||
|
// PLEASE NOTE: We do *not* want to slow down font parsing by adding
|
||||||
|
// `hasOwnProperty` checks all over the code-base.
|
||||||
|
const enumerableProperties = [];
|
||||||
|
for (const property in []) {
|
||||||
|
enumerableProperties.push(property);
|
||||||
|
}
|
||||||
|
if (enumerableProperties.length) {
|
||||||
|
throw new Error(
|
||||||
|
"The `Array.prototype` contains unexpected enumerable properties: " +
|
||||||
|
enumerableProperties.join(", ") +
|
||||||
|
"; thus breaking e.g. `for...in` iteration of `Array`s."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var docId = docParams.docId;
|
var docId = docParams.docId;
|
||||||
var docBaseUrl = docParams.docBaseUrl;
|
var docBaseUrl = docParams.docBaseUrl;
|
||||||
var workerHandlerName = docParams.docId + "_worker";
|
var workerHandlerName = docParams.docId + "_worker";
|
||||||
|
Loading…
Reference in New Issue
Block a user