From e8a0f80967020804a431dc48ac13f8bc85966fc2 Mon Sep 17 00:00:00 2001 From: Daniel Liebner Date: Mon, 30 Jan 2023 23:13:36 -0500 Subject: [PATCH] Handle htmlparser2.onclosetag isImplied parameter Style matching --- index.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 0185423..8c3346a 100644 --- a/index.js +++ b/index.js @@ -118,9 +118,7 @@ function sanitizeHtml(html, options, _recursing) { options.parser = Object.assign({}, htmlParserDefaults, options.parser); const tagAllowed = function (name) { - return options.allowedTags === false || (options.allowedTags || []).indexOf(name) > -1; - }; // vulnerableTags @@ -516,7 +514,7 @@ function sanitizeHtml(html, options, _recursing) { frame.text += text; } }, - onclosetag: function(name) { + onclosetag: function(name, isImplied) { if (skipText) { skipTextDepth--; @@ -569,8 +567,8 @@ function sanitizeHtml(html, options, _recursing) { if ( // Already output /> options.selfClosing.indexOf(name) !== -1 || - // Escaped tag - (!tagAllowed(name) && ['escape','recursiveEscape'].indexOf(options.disallowedTagsMode) >= 0) + // Escaped tag, closing tag is implied + (isImplied && !tagAllowed(name) && ['escape','recursiveEscape'].indexOf(options.disallowedTagsMode) >= 0) ) { if (skip) { result = tempResult;