sanitize-html 2.5.0 → 2.5.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.
- package/CHANGELOG.md +3 -0
- package/index.js +9 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.5.1 (2021-09-14):
|
|
4
|
+
- The `allowedScriptHostnames` and `allowedScriptDomains` options now implicitly purge the inline content of all script tags, not just those with `src` attributes. This behavior was already strongly implied by the fact that they purged it in the case where a `src` attribute was actually present, and is necessary for the feature to provide any real security. Thanks to Grigorii Duca for pointing out the issue.
|
|
5
|
+
|
|
3
6
|
## 2.5.0 (2021-09-08):
|
|
4
7
|
|
|
5
8
|
- New `allowedScriptHostnames` option, it enables you to specify which hostnames are allowed in a script tag.
|
package/index.js
CHANGED
|
@@ -265,6 +265,13 @@ function sanitizeHtml(html, options, _recursing) {
|
|
|
265
265
|
result = '';
|
|
266
266
|
}
|
|
267
267
|
result += '<' + name;
|
|
268
|
+
|
|
269
|
+
if (name === 'script') {
|
|
270
|
+
if (options.allowedScriptHostnames || options.allowedScriptDomains) {
|
|
271
|
+
frame.innerText = '';
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
268
275
|
if (!allowedAttributesMap || has(allowedAttributesMap, name) || allowedAttributesMap['*']) {
|
|
269
276
|
each(attribs, function(value, a) {
|
|
270
277
|
if (!VALID_HTML_ATTRIBUTE_NAME.test(a)) {
|
|
@@ -315,10 +322,10 @@ function sanitizeHtml(html, options, _recursing) {
|
|
|
315
322
|
return;
|
|
316
323
|
}
|
|
317
324
|
}
|
|
325
|
+
|
|
318
326
|
if (name === 'script' && a === 'src') {
|
|
319
|
-
let allowed = true;
|
|
320
327
|
|
|
321
|
-
|
|
328
|
+
let allowed = true;
|
|
322
329
|
|
|
323
330
|
try {
|
|
324
331
|
const parsed = new URL(value);
|
package/package.json
CHANGED