Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sanitize-html

Package Overview
Dependencies
Maintainers
13
Versions
114
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 1.5.2 to 1.5.3

7

index.js

@@ -165,3 +165,8 @@ var htmlparser = require('htmlparser2');

}
result += escapeHtml(text);
var tag = stack[stack.length-1] && stack[stack.length-1].tag;
if (_.has(nonTextTagsMap, tag)) {
result += text;
} else {
result += escapeHtml(text);
}
if (stack.length) {

@@ -168,0 +173,0 @@ var frame = stack[stack.length - 1];

2

package.json
{
"name": "sanitize-html",
"version": "1.5.2",
"version": "1.5.3",
"description": "Clean up user-submitted HTML, preserving whitelisted elements and whitelisted attributes on a per-element basis",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -192,2 +192,4 @@ # sanitize-html

1.5.3: do not escape special characters inside a script or style element, if they are allowed. This is consistent with the way browsers parse them; nothing closes them except the appropriate closing tag for the entire element. Of course, this only comes into play if you actually choose to allow those tags. Thanks to aletorrado.
1.5.2: guard checks for allowed attributes correctly to avoid an undefined property error. Thanks to Zeke.

@@ -194,0 +196,0 @@

@@ -324,2 +324,14 @@ var assert = require("assert");

});
it('should not escape inner content from non-text tags (when allowed)', function() {
assert.equal(
sanitizeHtml('<div>"normal text"</div><script>"this is code"</script>', {
allowedTags: [ 'script' ]
}), '&quot;normal text&quot;<script>"this is code"</script>'
);
assert.equal(
sanitizeHtml('<div>"normal text"</div><style>body { background-image: url("image.test"); }</style>', {
allowedTags: [ 'style' ]
}), '&quot;normal text&quot;<style>body { background-image: url("image.test"); }</style>'
);
});
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc