From 189ce4cd462a19ee8529bb9e11da32d204f7074f Mon Sep 17 00:00:00 2001 From: gardenapple Date: Fri, 29 Jan 2021 11:32:27 +0200 Subject: [PATCH] Sanitize whole HTML as DOM rather than string --- index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/index.js b/index.js index 509d1de..6ffbd89 100755 --- a/index.js +++ b/index.js @@ -497,11 +497,10 @@ function onLoadDOMError(error) { } function getHTML(window) { - let outputHTML = window.document.documentElement.outerHTML; if (!args["insane"]) { const createDOMPurify = require("dompurify"); const DOMPurify = createDOMPurify(window); - outputHTML = DOMPurify.sanitize(outputHTML, {WHOLE_DOCUMENT: true}); + outputHTML = DOMPurify.sanitize(window.document, {IN_PLACE: true, WHOLE_DOCUMENT: true}); } return outputHTML; }