Comparing version 1.0.5 to 2.0.1
@@ -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" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
9561
6
60
0
1
2
+ Addeddom-parser-mini@^2.0.2
+ Addeddom-parser-mini@2.0.2(transitive)