From 14fc9db73d56d6b115fb0992ec38381ed7936f18 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sun, 28 Mar 2021 17:36:51 +0200 Subject: [PATCH] Prevent errors, in `PDFOutlineViewer._getPageNumberToDestHash`, for invalid `destRef` values (PR 12777 follow-up) Currently `destRef === null`, which will only happen in documents with corrupt destinations, will (unsurprisingly) throw when trying to lookup the pageNumber. To avoid this, we can simply use the same format as in https://github.com/mozilla/pdf.js/blob/1a2cdaffc513385fc2f17d0e53d2643f92d5fa81/web/pdf_link_service.js#L128 --- web/pdf_outline_viewer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/pdf_outline_viewer.js b/web/pdf_outline_viewer.js index 83a142dd6..96c229012 100644 --- a/web/pdf_outline_viewer.js +++ b/web/pdf_outline_viewer.js @@ -276,7 +276,7 @@ class PDFOutlineViewer extends BaseTreeViewer { if (Array.isArray(explicitDest)) { const [destRef] = explicitDest; - if (typeof destRef === "object") { + if (destRef instanceof Object) { pageNumber = this.linkService._cachedPageNumber(destRef); if (!pageNumber) {