diff --git a/index.js b/index.js index 8c3346a..4363267 100644 --- a/index.js +++ b/index.js @@ -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; diff --git a/test/test.js b/test/test.js index eb9bcbb..92e91aa 100644 --- a/test/test.js +++ b/test/test.js @@ -1561,17 +1561,19 @@ describe('sanitizeHtml', function() { }), '' ); }); - 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('Hello', { - disallowedTagsMode: 'escape', + disallowedTagsMode: 'escape' }), '<test>Hello'); + }); + it('should not automatically attach close tag for escaped tags in recursiveEscape mode', function() { assert.equal(sanitizeHtml('Hello', { - disallowedTagsMode: 'recursiveEscape', + disallowedTagsMode: 'recursiveEscape' }), '<test><test><test><test><test>Hello'); }); it('should discard unclosed disallowed tags', function() { assert.equal(sanitizeHtml('Hello', { - disallowedTagsMode: 'discard', + disallowedTagsMode: 'discard' }), 'Hello'); }); });