From 9b43bec44e58b7d2f80a976db29272dc4edf87c6 Mon Sep 17 00:00:00 2001 From: gardenapple Date: Tue, 16 Mar 2021 19:18:12 +0200 Subject: [PATCH] Fix crash when sanitizing HTML --- index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 9dcd024..17b7a56 100755 --- a/index.js +++ b/index.js @@ -590,10 +590,11 @@ function onLoadDOMError(error) { } function getHTML(window) { + let html = window.document.documentElement.outerHTML; if (!args["insane"]) { const createDOMPurify = require("dompurify"); const DOMPurify = createDOMPurify(window); - outputHTML = DOMPurify.sanitize(window.document, {IN_PLACE: true, WHOLE_DOCUMENT: true}); + return DOMPurify.sanitize(html, {IN_PLACE: true, WHOLE_DOCUMENT: true}); } - return outputHTML; + return html; }