sanitize-html 2.17.4 → 2.17.5-alpha.1

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 +2 -2
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -566,13 +566,13 @@ function sanitizeHtml(html, options, _recursing) {
566
566
 
567
567
  if (options.disallowedTagsMode === 'completelyDiscard' && !tagAllowed(tag)) {
568
568
  text = '';
569
- } else if ((options.disallowedTagsMode === 'discard' || options.disallowedTagsMode === 'completelyDiscard') && ((tag === 'script') || (tag === 'style'))) {
569
+ } else if (tag && tagAllowed(tag) && (options.disallowedTagsMode === 'discard' || options.disallowedTagsMode === 'completelyDiscard') && ((tag === 'script') || (tag === 'style'))) {
570
570
  // htmlparser2 gives us these as-is. Escaping them ruins the content. Allowing
571
571
  // script tags is, by definition, game over for XSS protection, so if that's
572
572
  // your concern, don't allow them. The same is essentially true for style tags
573
573
  // which have their own collection of XSS vectors.
574
574
  result += text;
575
- } else if ((options.disallowedTagsMode === 'discard' || options.disallowedTagsMode === 'completelyDiscard') && (tag === 'textarea' || tag === 'xmp')) {
575
+ } else if (tag && tagAllowed(tag) && (options.disallowedTagsMode === 'discard' || options.disallowedTagsMode === 'completelyDiscard') && (tag === 'textarea' || tag === 'xmp')) {
576
576
  // htmlparser2 treats <textarea> and <xmp> as raw text elements and
577
577
  // does NOT decode entities inside them. The text is already properly
578
578
  // encoded, so pass it through without additional escaping to avoid
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sanitize-html",
3
- "version": "2.17.4",
3
+ "version": "2.17.5-alpha.1",
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",
@@ -28,7 +28,7 @@
28
28
  "is-plain-object": "^5.0.0",
29
29
  "parse-srcset": "^1.0.2",
30
30
  "postcss": "^8.3.11",
31
- "launder": "^1.7.1"
31
+ "launder": "^1.7.2-alpha.1"
32
32
  },
33
33
  "devDependencies": {
34
34
  "eslint": "^9.39.1",