sanitize-html 2.7.1 → 2.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +10 -2
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -117,7 +117,7 @@ function sanitizeHtml(html, options, _recursing) {
117
117
  // vulnerableTags
118
118
  vulnerableTags.forEach(function (tag) {
119
119
  if (
120
- options.allowedTags && options.allowedTags.indexOf(tag) > -1 &&
120
+ options.allowedTags !== false && (options.allowedTags || []).indexOf(tag) > -1 &&
121
121
  !options.allowVulnerableTags
122
122
  ) {
123
123
  console.warn(`\n\n⚠️ Your \`allowedTags\` option includes, \`${tag}\`, which is inherently\nvulnerable to XSS attacks. Please remove it from \`allowedTags\`.\nOr, to disable this warning, add the \`allowVulnerableTags\` option\nand ensure you are accounting for this risk.\n\n`);
@@ -251,7 +251,7 @@ function sanitizeHtml(html, options, _recursing) {
251
251
  }
252
252
  }
253
253
 
254
- if ((options.allowedTags && options.allowedTags.indexOf(name) === -1) || (options.disallowedTagsMode === 'recursiveEscape' && !isEmptyObject(skipMap)) || (options.nestingLimit != null && depth >= options.nestingLimit)) {
254
+ if ((options.allowedTags !== false && (options.allowedTags || []).indexOf(name) === -1) || (options.disallowedTagsMode === 'recursiveEscape' && !isEmptyObject(skipMap)) || (options.nestingLimit != null && depth >= options.nestingLimit)) {
255
255
  skip = true;
256
256
  skipMap[depth] = true;
257
257
  if (options.disallowedTagsMode === 'discard') {
@@ -521,6 +521,14 @@ function sanitizeHtml(html, options, _recursing) {
521
521
  // Do not crash on bad markup
522
522
  return;
523
523
  }
524
+
525
+ if (frame.tag !== name) {
526
+ // Another case of bad markup.
527
+ // Push to stack, so that it will be used in future closing tags.
528
+ stack.push(frame);
529
+ return;
530
+ }
531
+
524
532
  skipText = options.enforceHtmlBoundary ? name === 'html' : false;
525
533
  depth--;
526
534
  const skip = skipMap[depth];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sanitize-html",
3
- "version": "2.7.1",
3
+ "version": "2.7.3",
4
4
  "description": "Clean up user-submitted HTML, preserving allowlisted elements and allowlisted attributes on a per-element basis",
5
5
  "sideEffects": false,
6
6
  "main": "index.js",