You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

sanitize-html

Package Overview
Dependencies
Maintainers
16
Versions
120
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sanitize-html - npm Package Compare versions

Comparing version
2.16.0
to
2.17.0
+10
-2
index.js

@@ -303,4 +303,11 @@ const htmlparser = require('htmlparser2');

if (!allowedAttributesMap || has(allowedAttributesMap, name) || allowedAttributesMap['*']) {
const isBeingEscaped = skip && (options.disallowedTagsMode === 'escape' || options.disallowedTagsMode === 'recursiveEscape');
const shouldPreserveEscapedAttributes = isBeingEscaped && options.preserveEscapedAttributes;
if (shouldPreserveEscapedAttributes) {
each(attribs, function(value, a) {
result += ' ' + a + '="' + escapeHtml((value || ''), true) + '"';
});
} else if (!allowedAttributesMap || has(allowedAttributesMap, name) || allowedAttributesMap['*']) {
each(attribs, function(value, a) {
if (!VALID_HTML_ATTRIBUTE_NAME.test(a)) {

@@ -927,3 +934,4 @@ // This prevents part of an attribute name in the output from being

enforceHtmlBoundary: false,
parseStyleAttributes: true
parseStyleAttributes: true,
preserveEscapedAttributes: false
};

@@ -930,0 +938,0 @@

+1
-1
{
"name": "sanitize-html",
"version": "2.16.0",
"version": "2.17.0",
"description": "Clean up user-submitted HTML, preserving allowlisted elements and allowlisted attributes on a per-element basis",

@@ -5,0 +5,0 @@ "sideEffects": false,

@@ -748,3 +748,3 @@ # sanitize-html

if you set `disallowedTagsMode` to `recursiveEscape`, disallowed tag and its children will be escaped even for allowed tags
if you set `disallowedTagsMode` to `recursiveEscape`, disallowed tags and their children will be escaped even for allowed tags:

@@ -757,2 +757,11 @@ ```js

#### Escape the disallowed tag, including all its attributes.
By default, attributes are not preserved when tags are escaped. You can set `preserveEscapedAttributes` to `true` to
keep the attributes, which will also be escaped and therefore have no effect on the browser.
```js
preserveEscapedAttributes: true
```
### Ignore style attribute contents

@@ -759,0 +768,0 @@