sanitize-html 2.17.1 → 2.17.2

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 +7 -1
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -566,6 +566,11 @@ function sanitizeHtml(html, options, _recursing) {
566
566
  // your concern, don't allow them. The same is essentially true for style tags
567
567
  // which have their own collection of XSS vectors.
568
568
  result += text;
569
+ } else if ((options.disallowedTagsMode === 'discard' || options.disallowedTagsMode === 'completelyDiscard') && (nonTextTagsArray.indexOf(tag) !== -1)) {
570
+ // htmlparser2 does not decode entities inside raw text elements like
571
+ // textarea and option. The text is already properly encoded, so pass
572
+ // it through without additional escaping to avoid double-encoding.
573
+ result += text;
569
574
  } else if (!addedText) {
570
575
  const escaped = escapeHtml(text, false);
571
576
  if (options.textFilter) {
@@ -671,7 +676,8 @@ function sanitizeHtml(html, options, _recursing) {
671
676
 
672
677
  if (options.disallowedTagsMode === 'escape' || options.disallowedTagsMode === 'recursiveEscape') {
673
678
  const lastParsedIndex = parser.endIndex;
674
- if (lastParsedIndex != null && lastParsedIndex >= 0 && lastParsedIndex < html.length) {
679
+ if (lastParsedIndex != null && lastParsedIndex >= 0 &&
680
+ lastParsedIndex < html.length) {
675
681
  const unparsed = html.substring(lastParsedIndex);
676
682
  result += escapeHtml(unparsed);
677
683
  } else if ((lastParsedIndex == null || lastParsedIndex < 0) && html.length > 0 && result === '') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sanitize-html",
3
- "version": "2.17.1",
3
+ "version": "2.17.2",
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",
@@ -24,7 +24,7 @@
24
24
  "dependencies": {
25
25
  "deepmerge": "^4.2.2",
26
26
  "escape-string-regexp": "^4.0.0",
27
- "htmlparser2": "^8.0.0",
27
+ "htmlparser2": "^10.1.0",
28
28
  "is-plain-object": "^5.0.0",
29
29
  "parse-srcset": "^1.0.2",
30
30
  "postcss": "^8.3.11"