|
(function(t){var e="undefined"===typeof window?null:window;"function"===typeof define&&define.amd?define(function(){return t(e)}):"undefined"!==typeof module?module.exports=t(e):e.DOMPurify=t(e)})(function factory(e){var f=function(a){return factory(a)};f.version="0.6.5";if(!e||!e.document||9!==e.document.nodeType)return f.isSupported=!1,f;var k=e.document,x=k,y=e.DocumentFragment,q=e.NodeFilter,P=e.NamedNodeMap||e.MozNamedAttrMap,Q=e.Text,R=e.Comment;"function"===typeof e.HTMLTemplateElement&&(k= |
|
k.createElement("template").content.ownerDocument);var z=k.implementation,S=k.createNodeIterator,T=k.getElementsByTagName,U=k.createDocumentFragment,V=x.importNode,d={};f.isSupported="undefined"!==typeof z.createHTMLDocument&&9!==k.documentMode;var h=function(a,c){for(var b=c.length;b--;)a[c[b]]=!0;return a},A=function(a){var c={},b;for(b in a)a.hasOwnProperty(b)&&(c[b]=a[b]);return c},m=null,B=h({},"a abbr acronym address area article aside audio b bdi bdo big blink blockquote body br button canvas caption center cite code col colgroup content data datalist dd decorator del details dfn dir div dl dt element em fieldset figcaption figure font footer form h1 h2 h3 h4 h5 h6 head header hgroup hr html i img input ins kbd label legend li main map mark marquee menu menuitem meter nav nobr ol optgroup option output p pre progress q rp rt ruby s samp section select shadow small source spacer span strike strong style sub summary sup table tbody td template textarea tfoot th thead time tr track tt u ul var video wbr svg altglyph altglyphdef altglyphitem animatecolor animatemotion animatetransform circle clippath defs desc ellipse font g glyph glyphref hkern image line lineargradient marker mask metadata mpath path pattern polygon polyline radialgradient rect stop switch symbol text textpath title tref tspan view vkern math menclose merror mfenced mfrac mglyph mi mlabeledtr mmuliscripts mn mo mover mpadded mphantom mroot mrow ms mpspace msqrt mystyle msub msup msubsup mtable mtd mtext mtr munder munderover #text".split(" ")), |
|
n=null,C=h({},"accept action align alt autocomplete background bgcolor border cellpadding cellspacing checked cite class clear color cols colspan coords datetime default dir disabled download enctype face for headers height hidden high href hreflang id ismap label lang list loop low max maxlength media method min multiple name noshade novalidate nowrap open optimum pattern placeholder poster preload pubdate radiogroup readonly rel required rev reversed rows rowspan spellcheck scope selected shape size span srclang start src step style summary tabindex title type usemap valign value width xmlns accent-height accumulate additivive alignment-baseline ascent azimuth baseline-shift bias clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cx cy d dy dy direction display divisor dur elevation end fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight image-rendering in in2 k1 k2 k3 k4 kerning letter-spacing lighting-color local marker-end marker-mid marker-start max mask mode min offset operator opacity order overflow paint-order path points r rx ry radius restart scale seed shape-rendering stop-color stop-opacity stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke stroke-width transform text-anchor text-decoration text-rendering u1 u2 viewbox visibility word-spacing wrap writing-mode x x1 x2 y y1 y2 z accent accentunder bevelled close columnsalign columnlines columnspan denomalign depth display displaystyle fence frame largeop length linethickness lspace lquote mathbackground mathcolor mathsize mathvariant maxsize minsize movablelimits notation numalign open rowalign rowlines rowspacing rowspan rspace rquote scriptlevel scriptminsize scriptsizemultiplier selection separator separators stretchy subscriptshift supscriptshift symmetric voffset xlink:href xml:id xlink:title xml:space".split(" ")), |
|
D=null,E=null,F=!0,G=!1,r=!1,p=!1,u=!1,H=!1,I=!0,v=!0,W=h({},"audio head math script style svg video".split(" ")),J=null,X=k.createElement("form"),K=function(a){try{a.parentNode.removeChild(a)}catch(c){a.outerHTML=""}},L=function(a){return S.call(a.ownerDocument||a,a,q.SHOW_ELEMENT|q.SHOW_COMMENT|q.SHOW_TEXT,function(){return q.FILTER_ACCEPT},!1)},M=function(a){l("beforeSanitizeElements",a,null);var c;c=a instanceof Q||a instanceof R?!1:"string"===typeof a.nodeName&&"string"===typeof a.textContent&& |
|
"function"===typeof a.removeChild&&a.attributes instanceof P&&"function"===typeof a.removeAttribute&&"function"===typeof a.setAttribute?!1:!0;if(c)return K(a),!0;c=a.nodeName.toLowerCase();l("uponSanitizeElement",a,{tagName:c});if(!m[c]||D[c]){if(v&&!W[c]&&"function"===typeof a.insertAdjacentHTML)try{a.insertAdjacentHTML("AfterEnd",a.innerHTML)}catch(b){}K(a);return!0}G&&!a.firstElementChild&&(a.innerHTML=a.textContent.replace(/</g,"<"));l("afterSanitizeElements",a,null);return!1},N=function(a){l("beforeSanitizeAttributes", |
|
a,null);var c=a.attributes;if(c){for(var b={attrName:"",attrValue:"",keepAttr:!0},w=c.length,g,f,d,h;w--;)if(g=c[w],f=g.name,g=g.value,d=f.toLowerCase(),b.attrName=d,b.attrValue=g,b.keepAttr=!0,l("uponSanitizeAttribute",a,b),g=b.attrValue,"name"===d&&"IMG"===a.nodeName&&c.id?(h=c.id,c=Array.prototype.slice.apply(c),a.removeAttribute("id"),a.removeAttribute(f),c.indexOf(h)>w&&a.setAttribute("id",h.value)):a.removeAttribute(f),b.keepAttr&&(!I||"id"!==d&&"name"!==d||!(g in e||g in k||g in X))&&(n[d]&& |
|
!E[d]||F&&Y.test(d))&&(!Z.test(g.replace(aa,""))||"src"===d&&0===g.indexOf("data:")&&"IMG"===a.nodeName))try{a.setAttribute(f,g)}catch(m){}l("afterSanitizeAttributes",a,null)}},Y=/^data-[\w.\u00B7-\uFFFF-]/,Z=/^(?:\w+script|data):/i,aa=/[\x00-\x20\xA0\u1680\u180E\u2000-\u2029\u205f\u3000]/g,O=function(a){var c,b=L(a);for(l("beforeSanitizeShadowDOM",a,null);c=b.nextNode();)l("uponSanitizeShadowNode",c,null),M(c)||(c.content instanceof y&&O(c.content),N(c));l("afterSanitizeShadowDOM",a,null)},l=function(a, |
|
c,b){d[a]&&d[a].forEach(function(a){a.call(f,c,b,J)})};f.sanitize=function(a,c){if(!f.isSupported)return"function"===typeof e.toStaticHTML&&"string"===typeof a?e.toStaticHTML(a):a;var b=c;"object"!==typeof b&&(b={});m="ALLOWED_TAGS"in b?h({},b.ALLOWED_TAGS):B;n="ALLOWED_ATTR"in b?h({},b.ALLOWED_ATTR):C;D="FORBID_TAGS"in b?h({},b.FORBID_TAGS):{};E="FORBID_ATTR"in b?h({},b.FORBID_ATTR):{};F=!1!==b.ALLOW_DATA_ATTR;G=b.SAFE_FOR_JQUERY||!1;r=b.WHOLE_DOCUMENT||!1;p=b.RETURN_DOM||!1;u=b.RETURN_DOM_FRAGMENT|| |
|
!1;H=b.RETURN_DOM_IMPORT||!1;I=!1!==b.SANITIZE_DOM;v=!1!==b.KEEP_CONTENT;u&&(p=!0);b.ADD_TAGS&&(m===B&&(m=A(m)),h(m,b.ADD_TAGS));b.ADD_ATTR&&(n===C&&(n=A(n)),h(n,b.ADD_ATTR));v&&(m["#text"]=!0);Object&&"freeze"in Object&&Object.freeze(b);J=b;if(!p&&!r&&-1===a.indexOf("<"))return a;var b=z.createHTMLDocument(""),d=b.body;d.parentNode.removeChild(d.parentNode.firstElementChild);d.outerHTML=a;b=T.call(b,r?"html":"body")[0];if(!b)return p?null:"";for(var g=L(b);d=g.nextNode();)M(d)||(d.content instanceof |
|
y&&O(d.content),N(d));if(p){if(u)for(d=U.call(b.ownerDocument);b.firstChild;)d.appendChild(b.firstChild);else d=b;H&&(d=V.call(x,d,!0));return d}return r?b.outerHTML:b.innerHTML};f.addHook=function(a,c){"function"===typeof c&&(d[a]=d[a]||[],d[a].push(c))};f.removeHook=function(a){d[a]&&d[a].pop()};f.removeHooks=function(a){d[a]&&(d[a]=[])};f.removeAllHooks=function(){d=[]};return f}); |