sanitize-html 2.17.2 → 2.17.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.
- package/index.js +8 -4
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -566,10 +566,14 @@ 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') && (
|
|
570
|
-
// htmlparser2
|
|
571
|
-
//
|
|
572
|
-
// it through without additional escaping to avoid
|
|
569
|
+
} else if ((options.disallowedTagsMode === 'discard' || options.disallowedTagsMode === 'completelyDiscard') && (tag === 'textarea' || tag === 'xmp')) {
|
|
570
|
+
// htmlparser2 treats <textarea> and <xmp> as raw text elements and
|
|
571
|
+
// does NOT decode entities inside them. The text is already properly
|
|
572
|
+
// encoded, so pass it through without additional escaping to avoid
|
|
573
|
+
// double-encoding. Other "nonTextTags" like <option> are not raw text
|
|
574
|
+
// elements in htmlparser2, so their contents are decoded and must be
|
|
575
|
+
// escaped below like any other text (important to prevent XSS via
|
|
576
|
+
// entity-encoded payloads such as <option><script>...</script></option>).
|
|
573
577
|
result += text;
|
|
574
578
|
} else if (!addedText) {
|
|
575
579
|
const escaped = escapeHtml(text, false);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sanitize-html",
|
|
3
|
-
"version": "2.17.
|
|
3
|
+
"version": "2.17.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",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"eslint": "^9.39.1",
|
|
34
|
-
"mocha": "^
|
|
34
|
+
"mocha": "^11.7.5",
|
|
35
35
|
"sinon": "^9.0.2",
|
|
36
36
|
"eslint-config-apostrophe": "^6.0.2"
|
|
37
37
|
},
|