Improve the pageNumber validation in BaseViewer.isPageVisible (PR 10217 follow-up)

This commit is contained in:
Jonas Jenwald 2020-11-12 15:24:36 +01:00
parent 85de01e34b
commit 8b5bc8d7f9

View File

@ -1096,9 +1096,15 @@ class BaseViewer {
if (!this.pdfDocument) { if (!this.pdfDocument) {
return false; return false;
} }
if (pageNumber < 1 || pageNumber > this.pagesCount) { if (
!(
Number.isInteger(pageNumber) &&
pageNumber > 0 &&
pageNumber <= this.pagesCount
)
) {
console.error( console.error(
`${this._name}.isPageVisible: "${pageNumber}" is out of bounds.` `${this._name}.isPageVisible: "${pageNumber}" is not a valid page.`
); );
return false; return false;
} }