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.7.1 to 1.7.2

29

index.js
var htmlparser = require('htmlparser2');
var extend = require('xtend');
var quoteRegexp = require('regexp-quote');
require('array-includes').shim(); // Array.prototype.includes polyfill
function each(obj, cb) {
obj && Object.keys(obj).forEach(function (key) {
cb(obj[key], key)
})
if (obj) Object.keys(obj).forEach(function (key) {
cb(obj[key], key);
});
}

@@ -106,5 +105,5 @@

if (options.allowedTags && !options.allowedTags.includes(name)) {
if (options.allowedTags && options.allowedTags.indexOf(name) === -1) {
skip = true;
if (nonTextTagsArray.includes(name)) {
if (nonTextTagsArray.indexOf(name) !== -1) {
skipText = true;

@@ -122,3 +121,3 @@ }

each(attribs, function(value, a) {
if (!allowedAttributesMap || allowedAttributesMap[name].includes(a) ||
if (!allowedAttributesMap || allowedAttributesMap[name].indexOf(a) !== -1 ||
(allowedAttributesGlobMap[name] && allowedAttributesGlobMap[name].test(a))) {

@@ -147,3 +146,3 @@ if ((a === 'href') || (a === 'src')) {

}
if (options.selfClosing.includes(name)) {
if (options.selfClosing.indexOf(name) !== -1) {
result += " />";

@@ -159,3 +158,3 @@ } else {

var tag = stack[stack.length-1] && stack[stack.length-1].tag;
if (nonTextTagsArray.includes(tag)) {
if (nonTextTagsArray.indexOf(tag) !== -1) {
result += text;

@@ -201,3 +200,3 @@ } else {

if (options.selfClosing.includes(name)) {
if (options.selfClosing.indexOf(name) !== -1) {
// Already output />

@@ -241,6 +240,6 @@ return;

if (options.allowedSchemesByTag[name]) {
return !options.allowedSchemesByTag[name].includes(scheme);
return options.allowedSchemesByTag[name].indexOf(scheme) === -1;
}
return !options.allowedSchemes || !options.allowedSchemes.includes(scheme);
return !options.allowedSchemes || options.allowedSchemes.indexOf(scheme) === -1;
}

@@ -255,3 +254,3 @@

return classes.filter(function(clss) {
return allowed.includes(clss);
return allowed.indexOf(clss) !== -1;
}).join(' ');

@@ -265,3 +264,5 @@ }

sanitizeHtml.defaults = {
allowedTags: [ 'h3', 'h4', 'h5', 'h6', 'blockquote', 'p', 'a', 'ul', 'ol', 'nl', 'li', 'b', 'i', 'strong', 'em', 'strike', 'code', 'hr', 'br', 'div', 'table', 'thead', 'caption', 'tbody', 'tr', 'th', 'td', 'pre' ],
allowedTags: [ 'h3', 'h4', 'h5', 'h6', 'blockquote', 'p', 'a', 'ul', 'ol',
'nl', 'li', 'b', 'i', 'strong', 'em', 'strike', 'code', 'hr', 'br', 'div',
'table', 'thead', 'caption', 'tbody', 'tr', 'th', 'td', 'pre' ],
allowedAttributes: {

@@ -268,0 +269,0 @@ a: [ 'href', 'name', 'target' ],

{
"name": "sanitize-html",
"version": "1.7.1",
"version": "1.7.2",
"description": "Clean up user-submitted HTML, preserving whitelisted elements and whitelisted attributes on a per-element basis",

@@ -24,3 +24,2 @@ "main": "index.js",

"dependencies": {
"array-includes": "^2.0.0",
"htmlparser2": "3.8.x",

@@ -27,0 +26,0 @@ "regexp-quote": "0.0.0",

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

1.7.2: removed `array-includes` dependency in favor of `indexOf`, which is a little more verbose but slightly faster and doesn't require a shim. Thanks again to Joseph Dykstra.
1.7.1: removed lodash dependency, adding lighter dependencies and polyfills in its place. Thanks to Joseph Dykstra.

@@ -229,0 +231,0 @@

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