From 6353a8d1a11d620ad7e182c3725517b79ada8ca8 Mon Sep 17 00:00:00 2001 From: Kyle Taylor Date: Fri, 28 Jun 2019 17:32:25 -0500 Subject: [PATCH] Check for HTMLAnchorElement properties on links - Also check in the case when results are undefined or not of array type - Only logs error and skips. Throw Error/Catch returns no data - fixes #2694 --- src/drivers/npm/driver.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/drivers/npm/driver.js b/src/drivers/npm/driver.js index 23e397ce6..4b1ee7974 100644 --- a/src/drivers/npm/driver.js +++ b/src/drivers/npm/driver.js @@ -242,6 +242,15 @@ class Driver { const reducedLinks = Array.prototype.reduce.call( browser.links, (results, link) => { + // Catch broken links. + if (!link.protocol) { + this.wappalyzer.log("Element is not a valid link interface.", "driver", "error"); + return; + } + if (results == null || !results.hasOwnProperty("push")) { + this.wappalyzer.log("Result object is not an array.", "driver", "error"); + return; + } if (link.protocol.match(/https?:/) && link.hostname === this.origPageUrl.hostname && extensions.test(link.pathname)) { link.hash = '';