Skip to content

Commit

Permalink
Handle htmlparser2.onclosetag isImplied parameter
Browse files Browse the repository at this point in the history
Style matching
  • Loading branch information
dliebner committed Jan 31, 2023
1 parent 1d41e4d commit e8a0f80
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -516,7 +514,7 @@ function sanitizeHtml(html, options, _recursing) {
frame.text += text;
}
},
onclosetag: function(name) {
onclosetag: function(name, isImplied) {

if (skipText) {
skipTextDepth--;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit e8a0f80

Please sign in to comment.