mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 01:58:06 +02:00
[api-minor] Let Catalog_getPageIndex
check that the Ref
actually points to a /Page dictionary
Currently the `getPageIndex` method will happily return `0`, even if the `Ref` parameter doesn't actually point to a proper /Page dictionary. Having the API trust that the consumer is doing the right thing seems error-prone, hence this patch which adds a check for this case. Given that the `Catalog_getPageIndex` method isn't used in any hot part of the codebase, this extra check shouldn't be a problem. (Note: in the standard viewer, it is only ever used from `PDFLinkService_navigateTo` if a destination needs to be resolved during document loading, which isn't common enough to be an issue IMHO.)
This commit is contained in:
parent
db46829ef7
commit
01ab15a6f1
5 changed files with 46 additions and 5 deletions
|
@ -290,6 +290,10 @@ function isRef(v) {
|
|||
return v instanceof Ref;
|
||||
}
|
||||
|
||||
function isRefsEqual(v1, v2) {
|
||||
return v1.num === v2.num && v1.gen === v2.gen;
|
||||
}
|
||||
|
||||
function isStream(v) {
|
||||
return typeof v === 'object' && v !== null && v.getBytes !== undefined;
|
||||
}
|
||||
|
@ -304,5 +308,6 @@ exports.isCmd = isCmd;
|
|||
exports.isDict = isDict;
|
||||
exports.isName = isName;
|
||||
exports.isRef = isRef;
|
||||
exports.isRefsEqual = isRefsEqual;
|
||||
exports.isStream = isStream;
|
||||
}));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue