From 901a2d41beb564c278c049f5738930a259fa8f50 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sat, 22 Oct 2016 22:57:27 +0200 Subject: [PATCH] Avoid accidentally rejecting a named destination that looks like a decimal number or a boolean (PR 7341 follow-up) Without this patch, the following link does not work correctly: http://unesdoc.unesco.org/images/0013/001346/134685E.pdf#4.3 Compare the correct behaviour of this link: http://unesdoc.unesco.org/images/0013/001346/134685E.pdf#nameddest=4.3 --- web/pdf_link_service.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/web/pdf_link_service.js b/web/pdf_link_service.js index 045913a56..8a9349c19 100644 --- a/web/pdf_link_service.js +++ b/web/pdf_link_service.js @@ -264,6 +264,12 @@ var PDFLinkService = (function PDFLinkServiceClosure() { dest = unescape(hash); try { dest = JSON.parse(dest); + + if (!(dest instanceof Array)) { + // Avoid incorrectly rejecting a valid named destination, such as + // e.g. "4.3" or "true", because `JSON.parse` converted its type. + dest = dest.toString(); + } } catch (ex) {} if (typeof dest === 'string' || isValidExplicitDestination(dest)) {