mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-08-02 04:17:24 +02:00
Add more validation in the Catalog.prototype.getPageIndex method
- Ensure that the /Kids-entries are Arrays, before trying to iterate through them. - Ensure that the /Count-entries are (positive) integers.
This commit is contained in:
parent
a1b7d0feb5
commit
339f755a52
@ -1495,6 +1495,9 @@ class Catalog {
|
|||||||
if (!kids) {
|
if (!kids) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
if (!Array.isArray(kids)) {
|
||||||
|
throw new FormatError("Kids must be an array.");
|
||||||
|
}
|
||||||
|
|
||||||
const kidPromises = [];
|
const kidPromises = [];
|
||||||
let found = false;
|
let found = false;
|
||||||
@ -1512,11 +1515,15 @@ class Catalog {
|
|||||||
throw new FormatError("Kid node must be a dictionary.");
|
throw new FormatError("Kid node must be a dictionary.");
|
||||||
}
|
}
|
||||||
if (obj.has("Count")) {
|
if (obj.has("Count")) {
|
||||||
total += obj.get("Count");
|
const count = obj.get("Count");
|
||||||
} else {
|
if (Number.isInteger(count) && count >= 0) {
|
||||||
|
total += count;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
throw new FormatError("Count must be a (positive) integer.");
|
||||||
|
}
|
||||||
// Page leaf node.
|
// Page leaf node.
|
||||||
total++;
|
total++;
|
||||||
}
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user