Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
dliebner committed Feb 1, 2023
1 parent f9b6fa5 commit 6ea35ad
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ function sanitizeHtml(html, options, _recursing) {
// Already output />
options.selfClosing.indexOf(name) !== -1 ||
// Escaped tag, closing tag is implied
(isImplied && !tagAllowed(name) && ['escape','recursiveEscape'].indexOf(options.disallowedTagsMode) >= 0)
(isImplied && !tagAllowed(name) && [ 'escape', 'recursiveEscape' ].indexOf(options.disallowedTagsMode) >= 0)
) {
if (skip) {
result = tempResult;
Expand Down
10 changes: 6 additions & 4 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1561,17 +1561,19 @@ describe('sanitizeHtml', function() {
}), '<script src="//example.com/script.js"></script>'
);
});
it('should not automatically attach close tag for escaped tags', function() {
it('should not automatically attach close tag for escaped tags in escape mode', function() {
assert.equal(sanitizeHtml('<test>Hello', {
disallowedTagsMode: 'escape',
disallowedTagsMode: 'escape'
}), '&lt;test&gt;Hello');
});
it('should not automatically attach close tag for escaped tags in recursiveEscape mode', function() {
assert.equal(sanitizeHtml('<test><test><test><test><test>Hello', {
disallowedTagsMode: 'recursiveEscape',
disallowedTagsMode: 'recursiveEscape'
}), '&lt;test&gt;&lt;test&gt;&lt;test&gt;&lt;test&gt;&lt;test&gt;Hello');
});
it('should discard unclosed disallowed tags', function() {
assert.equal(sanitizeHtml('<test>Hello', {
disallowedTagsMode: 'discard',
disallowedTagsMode: 'discard'
}), 'Hello');
});
});

0 comments on commit 6ea35ad

Please sign in to comment.