mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-25 09:38:06 +02:00
Validate even more dictionary properties
This checks primarily Arrays, but also some other properties, that we'll end up sending (sometimes indirectly) to the main-thread.
This commit is contained in:
parent
1b811ac113
commit
52f7ff155d
8 changed files with 125 additions and 64 deletions
|
@ -218,6 +218,21 @@ function isWhiteSpace(ch) {
|
|||
return ch === 0x20 || ch === 0x09 || ch === 0x0d || ch === 0x0a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if something is an Array containing only boolean values,
|
||||
* and (optionally) checks its length.
|
||||
* @param {any} arr
|
||||
* @param {number | null} len
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function isBooleanArray(arr, len) {
|
||||
return (
|
||||
Array.isArray(arr) &&
|
||||
(len === null || arr.length === len) &&
|
||||
arr.every(x => typeof x === "boolean")
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if something is an Array containing only numbers,
|
||||
* and (optionally) checks its length.
|
||||
|
@ -652,6 +667,7 @@ export {
|
|||
getRotationMatrix,
|
||||
getSizeInBytes,
|
||||
isAscii,
|
||||
isBooleanArray,
|
||||
isNumberArray,
|
||||
isWhiteSpace,
|
||||
log2,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue