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

xss-mini

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xss-mini - npm Package Compare versions

Comparing version 1.0.5 to 2.0.1

dist/sanitizeHtml.js

2

dist/sanitizeHtml.min.js

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const defaultAllowedTags=["b","i","em","strong","a","p","br","ul","ol","li","span","div","h1","h2","h3","h4","h5","h6"],defaultAllowedAttributes={a:["href","title"],img:["src","alt"],"*":["class","style"]};function xss(e,t=defaultAllowedTags,r=defaultAllowedAttributes){const o=document.createElement("div");function a(e){if(e.nodeType===Node.ELEMENT_NODE){const o=e;if(!t.includes(o.tagName.toLowerCase()))return void o.parentNode?.removeChild(o);Array.from(o.attributes).forEach((e=>{r[o.tagName.toLowerCase()]?.includes(e.name)||r["*"].includes(e.name)||o.removeAttribute(e.name)}))}Array.from(e.childNodes).forEach((e=>a(e)))}return o.innerHTML=e,Array.from(o.childNodes).forEach((e=>a(e))),o.innerHTML}exports.default=xss;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const dom_parser_mini_1=require("dom-parser-mini"),defaultAllowedTags=["b","i","em","strong","a","p","br","ul","ol","li","span","div","h1","h2","h3","h4","h5","h6","img","table","tr","td","th","thead","tbody","tfoot","col","colgroup","caption","blockquote","code","pre","hr","dl","dt","dd","kbd","q","samp","var","sub","sup","small","big","abbr","address","article","aside","audio","bdi","bdo","button","canvas","cite","data","datalist","del","details","dfn","dialog","fieldset","figcaption","figure","footer","form","header","input","label","legend","main","mark","meter","nav","noscript","object","optgroup","option","output","picture","progress","ruby","rt","rp","s","section","select","source","summary","template","textarea","time","track","u","video","wbr"],defaultAllowedAttributes={a:["href","title","target","rel"],img:["src","alt","width","height"],table:["border","cellpadding","cellspacing","summary"],col:["span","width"],colgroup:["span","width"],th:["colspan","rowspan","headers","scope","abbr"],td:["colspan","rowspan","headers","scope","abbr"],input:["type","value","name","placeholder","checked","disabled","readonly","size","maxlength","min","max","pattern","step"],button:["type","name","value","disabled"],form:["action","method","enctype","accept-charset","autocomplete","novalidate"],label:["for"],textarea:["name","rows","cols","disabled","readonly","placeholder"],select:["name","size","multiple","disabled"],optgroup:["label","disabled"],option:["value","label","selected","disabled"],audio:["src","controls","autoplay","loop","muted","preload"],video:["src","width","height","controls","autoplay","loop","muted","poster","preload"],source:["src","type","media"],track:["src","kind","srclang","label","default"],iframe:["src","width","height","name","sandbox","seamless","srcdoc"],"*":["class","style","id","title","lang","dir","data-*","role","tabindex","accesskey","contenteditable","draggable","hidden","spellcheck"]};function cleanNode(e,t,a){if(!t.includes(e.tagName))return void e.remove();const l=new Set;for(const e in a)a[e].forEach((e=>l.add(e)));e.filterAttributes(Array.from(l)),e.children.forEach((e=>cleanNode(e,t,a)))}function xss(e,t=defaultAllowedTags,a=defaultAllowedAttributes){const l=dom_parser_mini_1.default.create(e);return l.forEach((e=>cleanNode(e,t,a))),l.map((e=>e.html())).join("")}exports.default=xss;
{
"name": "xss-mini",
"version": "1.0.5",
"version": "2.0.1",
"description": "A lightweight library for sanitizing HTML input to prevent XSS attacks.",

@@ -31,3 +31,6 @@ "main": "dist/sanitizeHtml.min.js",

"typescript": "^5.4.5"
},
"dependencies": {
"dom-parser-mini": "^2.0.2"
}
}
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