4 lines
27 KiB
JavaScript
4 lines
27 KiB
JavaScript
/*! @license DOMPurify 3.4.10 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.10/LICENSE */function we(n,o){(o==null||o>n.length)&&(o=n.length);for(var s=0,l=Array(o);s<o;s++)l[s]=n[s];return l}function On(n){if(Array.isArray(n))return n}function Rn(n,o){var s=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(s!=null){var l,u,m,R,rt=[],w=!0,it=!1;try{if(m=(s=s.call(n)).next,o!==0)for(;!(w=(l=m.call(s)).done)&&(rt.push(l.value),rt.length!==o);w=!0);}catch(It){it=!0,u=It}finally{try{if(!w&&s.return!=null&&(R=s.return(),Object(R)!==R))return}finally{if(it)throw u}}return rt}}function Nn(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function In(n,o){return On(n)||Rn(n,o)||Dn(n,o)||Nn()}function Dn(n,o){if(n){if(typeof n=="string")return we(n,o);var s={}.toString.call(n).slice(8,-1);return s==="Object"&&n.constructor&&(s=n.constructor.name),s==="Map"||s==="Set"?Array.from(n):s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s)?we(n,o):void 0}}const Ye=Object.entries,Me=Object.setPrototypeOf,Ln=Object.isFrozen,wn=Object.getPrototypeOf,Mn=Object.getOwnPropertyDescriptor;let b=Object.freeze,O=Object.seal,ot=Object.create,je=typeof Reflect<"u"&&Reflect,Qt=je.apply,te=je.construct;b||(b=function(o){return o});O||(O=function(o){return o});Qt||(Qt=function(o,s){for(var l=arguments.length,u=new Array(l>2?l-2:0),m=2;m<l;m++)u[m-2]=arguments[m];return o.apply(s,u)});te||(te=function(o){for(var s=arguments.length,l=new Array(s>1?s-1:0),u=1;u<s;u++)l[u-1]=arguments[u];return new o(...l)});const mt=E(Array.prototype.forEach),Cn=E(Array.prototype.lastIndexOf),Ce=E(Array.prototype.pop),nt=E(Array.prototype.push),Pn=E(Array.prototype.splice),Y=Array.isArray,_t=E(String.prototype.toLowerCase),Vt=E(String.prototype.toString),Pe=E(String.prototype.match),dt=E(String.prototype.replace),xe=E(String.prototype.indexOf),xn=E(String.prototype.trim),kn=E(Number.prototype.toString),vn=E(Boolean.prototype.toString),ke=typeof BigInt>"u"?null:E(BigInt.prototype.toString),ve=typeof Symbol>"u"?null:E(Symbol.prototype.toString),D=E(Object.prototype.hasOwnProperty),Tt=E(Object.prototype.toString),S=E(RegExp.prototype.test),q=Un(TypeError);function E(n){return function(o){o instanceof RegExp&&(o.lastIndex=0);for(var s=arguments.length,l=new Array(s>1?s-1:0),u=1;u<s;u++)l[u-1]=arguments[u];return Qt(n,o,l)}}function Un(n){return function(){for(var o=arguments.length,s=new Array(o),l=0;l<o;l++)s[l]=arguments[l];return te(n,s)}}function f(n,o){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:_t;if(Me&&Me(n,null),!Y(o))return n;let l=o.length;for(;l--;){let u=o[l];if(typeof u=="string"){const m=s(u);m!==u&&(Ln(o)||(o[l]=m),u=m)}n[u]=!0}return n}function Fn(n){for(let o=0;o<n.length;o++)D(n,o)||(n[o]=null);return n}function I(n){const o=ot(null);for(const l of Ye(n)){var s=In(l,2);const u=s[0],m=s[1];D(n,u)&&(Y(m)?o[u]=Fn(m):m&&typeof m=="object"&&m.constructor===Object?o[u]=I(m):o[u]=m)}return o}function zn(n){switch(typeof n){case"string":return n;case"number":return kn(n);case"boolean":return vn(n);case"bigint":return ke?ke(n):"0";case"symbol":return ve?ve(n):"Symbol()";case"undefined":return Tt(n);case"function":case"object":{if(n===null)return Tt(n);const o=n,s=U(o,"toString");if(typeof s=="function"){const l=s(o);return typeof l=="string"?l:Tt(l)}return Tt(n)}default:return Tt(n)}}function U(n,o){for(;n!==null;){const l=Mn(n,o);if(l){if(l.get)return E(l.get);if(typeof l.value=="function")return E(l.value)}n=wn(n)}function s(){return null}return s}function Hn(n){try{return S(n,""),!0}catch{return!1}}const Ue=b(["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","dialog","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","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","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"]),qt=b(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Kt=b(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Gn=b(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Zt=b(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Bn=b(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Fe=b(["#text"]),ze=b(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Jt=b(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),He=b(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","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","width","xmlns"]),Nt=b(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Wn=O(/{{[\w\W]*|^[\w\W]*}}/g),Yn=O(/<%[\w\W]*|^[\w\W]*%>/g),jn=O(/\${[\w\W]*/g),$n=O(/^data-[\-\w.\u00B7-\uFFFF]+$/),Xn=O(/^aria-[\-\w]+$/),Ge=O(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Vn=O(/^(?:\w+script|data):/i),qn=O(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Kn=O(/^html$/i),Zn=O(/^[a-z][.\w]*(-[.\w]+)+$/i),Be=O(/<[/\w!]/g),Jn=O(/<[/\w]/g),Qn=O(/<\/no(script|embed|frames)/i),to=O(/\/>/i),v={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},eo=function(){return typeof window>"u"?null:window},no=function(o,s){if(typeof o!="object"||typeof o.createPolicy!="function")return null;let l=null;const u="data-tt-policy-suffix";s&&s.hasAttribute(u)&&(l=s.getAttribute(u));const m="dompurify"+(l?"#"+l:"");try{return o.createPolicy(m,{createHTML(R){return R},createScriptURL(R){return R}})}catch{return console.warn("TrustedTypes policy "+m+" could not be created."),null}},We=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},W=function(o,s,l,u){return D(o,s)&&Y(o[s])?f(u.base?I(u.base):{},o[s],u.transform):l};function $e(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:eo();const o=i=>$e(i);if(o.version="3.4.10",o.removed=[],!n||!n.document||n.document.nodeType!==v.document||!n.Element)return o.isSupported=!1,o;let s=n.document;const l=s,u=l.currentScript;n.DocumentFragment;const m=n.HTMLTemplateElement,R=n.Node,rt=n.Element,w=n.NodeFilter,it=n.NamedNodeMap;it===void 0&&(n.NamedNodeMap||n.MozNamedAttrMap),n.HTMLFormElement;const It=n.DOMParser,ht=n.trustedTypes,j=rt.prototype,Xe=U(j,"cloneNode"),ee=U(j,"remove"),Ve=U(j,"nextSibling"),at=U(j,"childNodes"),st=U(j,"parentNode"),ne=U(j,"shadowRoot"),Dt=U(j,"attributes"),M=R&&R.prototype?U(R.prototype,"nodeType"):null,z=R&&R.prototype?U(R.prototype,"nodeName"):null;if(typeof m=="function"){const i=s.createElement("template");i.content&&i.content.ownerDocument&&(s=i.content.ownerDocument)}let L,$="",Lt,oe=!1,lt=0;const re=function(){if(lt>0)throw q('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},K=function(t){re(),lt++;try{return L.createHTML(t)}finally{lt--}},qe=function(t){re(),lt++;try{return L.createScriptURL(t)}finally{lt--}},Ke=function(){return oe||(Lt=no(ht,u),oe=!0),Lt},gt=s,wt=gt.implementation,ie=gt.createNodeIterator,Ze=gt.createDocumentFragment,Je=gt.getElementsByTagName,Qe=l.importNode;let A=We();o.isSupported=typeof Ye=="function"&&typeof st=="function"&&wt&&wt.createHTMLDocument!==void 0;const tn=Wn,en=Yn,nn=jn,on=$n,rn=Xn,an=Vn,ae=qn,sn=Zn;let se=Ge,_=null;const Mt=f({},[...Ue,...qt,...Kt,...Zt,...Fe]);let h=null;const Ct=f({},[...ze,...Jt,...He,...Nt]);let d=Object.seal(ot(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),ct=null,le=null;const H=Object.seal(ot(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let ce=!0,Pt=!0,ue=!1,fe=!0,G=!1,ut=!0,X=!1,xt=!1,kt=!1,Z=!1,Et=!1,At=!1,pe=!0,me=!1;const de="user-content-";let vt=!0,Ut=!1,J={},x=null;const Ft=f({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let Te=null;const _e=f({},["audio","video","img","source","image","track"]);let zt=null;const he=f({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),yt="http://www.w3.org/1998/Math/MathML",St="http://www.w3.org/2000/svg",k="http://www.w3.org/1999/xhtml";let Q=k,Ht=!1,Gt=null;const ln=f({},[yt,St,k],Vt),ge=b(["mi","mo","mn","ms","mtext"]);let Bt=f({},ge);const Ee=b(["annotation-xml"]);let Wt=f({},Ee);const cn=f({},["title","style","font","a","script"]);let ft=null;const un=["application/xhtml+xml","text/html"],fn="text/html";let T=null,tt=null;const pn=s.createElement("form"),Ae=function(t){return t instanceof RegExp||t instanceof Function},Yt=function(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(tt&&tt===t)return;(!t||typeof t!="object")&&(t={}),t=I(t),ft=un.indexOf(t.PARSER_MEDIA_TYPE)===-1?fn:t.PARSER_MEDIA_TYPE,T=ft==="application/xhtml+xml"?Vt:_t,_=W(t,"ALLOWED_TAGS",Mt,{transform:T}),h=W(t,"ALLOWED_ATTR",Ct,{transform:T}),Gt=W(t,"ALLOWED_NAMESPACES",ln,{transform:Vt}),zt=W(t,"ADD_URI_SAFE_ATTR",he,{transform:T,base:he}),Te=W(t,"ADD_DATA_URI_TAGS",_e,{transform:T,base:_e}),x=W(t,"FORBID_CONTENTS",Ft,{transform:T}),ct=W(t,"FORBID_TAGS",I({}),{transform:T}),le=W(t,"FORBID_ATTR",I({}),{transform:T}),J=D(t,"USE_PROFILES")?t.USE_PROFILES&&typeof t.USE_PROFILES=="object"?I(t.USE_PROFILES):t.USE_PROFILES:!1,ce=t.ALLOW_ARIA_ATTR!==!1,Pt=t.ALLOW_DATA_ATTR!==!1,ue=t.ALLOW_UNKNOWN_PROTOCOLS||!1,fe=t.ALLOW_SELF_CLOSE_IN_ATTR!==!1,G=t.SAFE_FOR_TEMPLATES||!1,ut=t.SAFE_FOR_XML!==!1,X=t.WHOLE_DOCUMENT||!1,Z=t.RETURN_DOM||!1,Et=t.RETURN_DOM_FRAGMENT||!1,At=t.RETURN_TRUSTED_TYPE||!1,kt=t.FORCE_BODY||!1,pe=t.SANITIZE_DOM!==!1,me=t.SANITIZE_NAMED_PROPS||!1,vt=t.KEEP_CONTENT!==!1,Ut=t.IN_PLACE||!1,se=Hn(t.ALLOWED_URI_REGEXP)?t.ALLOWED_URI_REGEXP:Ge,Q=typeof t.NAMESPACE=="string"?t.NAMESPACE:k,Bt=D(t,"MATHML_TEXT_INTEGRATION_POINTS")&&t.MATHML_TEXT_INTEGRATION_POINTS&&typeof t.MATHML_TEXT_INTEGRATION_POINTS=="object"?I(t.MATHML_TEXT_INTEGRATION_POINTS):f({},ge),Wt=D(t,"HTML_INTEGRATION_POINTS")&&t.HTML_INTEGRATION_POINTS&&typeof t.HTML_INTEGRATION_POINTS=="object"?I(t.HTML_INTEGRATION_POINTS):f({},Ee);const e=D(t,"CUSTOM_ELEMENT_HANDLING")&&t.CUSTOM_ELEMENT_HANDLING&&typeof t.CUSTOM_ELEMENT_HANDLING=="object"?I(t.CUSTOM_ELEMENT_HANDLING):ot(null);if(d=ot(null),D(e,"tagNameCheck")&&Ae(e.tagNameCheck)&&(d.tagNameCheck=e.tagNameCheck),D(e,"attributeNameCheck")&&Ae(e.attributeNameCheck)&&(d.attributeNameCheck=e.attributeNameCheck),D(e,"allowCustomizedBuiltInElements")&&typeof e.allowCustomizedBuiltInElements=="boolean"&&(d.allowCustomizedBuiltInElements=e.allowCustomizedBuiltInElements),O(d),G&&(Pt=!1),Et&&(Z=!0),J&&(_=f({},Fe),h=ot(null),J.html===!0&&(f(_,Ue),f(h,ze)),J.svg===!0&&(f(_,qt),f(h,Jt),f(h,Nt)),J.svgFilters===!0&&(f(_,Kt),f(h,Jt),f(h,Nt)),J.mathMl===!0&&(f(_,Zt),f(h,He),f(h,Nt))),H.tagCheck=null,H.attributeCheck=null,D(t,"ADD_TAGS")&&(typeof t.ADD_TAGS=="function"?H.tagCheck=t.ADD_TAGS:Y(t.ADD_TAGS)&&(_===Mt&&(_=I(_)),f(_,t.ADD_TAGS,T))),D(t,"ADD_ATTR")&&(typeof t.ADD_ATTR=="function"?H.attributeCheck=t.ADD_ATTR:Y(t.ADD_ATTR)&&(h===Ct&&(h=I(h)),f(h,t.ADD_ATTR,T))),D(t,"ADD_URI_SAFE_ATTR")&&Y(t.ADD_URI_SAFE_ATTR)&&f(zt,t.ADD_URI_SAFE_ATTR,T),D(t,"FORBID_CONTENTS")&&Y(t.FORBID_CONTENTS)&&(x===Ft&&(x=I(x)),f(x,t.FORBID_CONTENTS,T)),D(t,"ADD_FORBID_CONTENTS")&&Y(t.ADD_FORBID_CONTENTS)&&(x===Ft&&(x=I(x)),f(x,t.ADD_FORBID_CONTENTS,T)),vt&&(_["#text"]=!0),X&&f(_,["html","head","body"]),_.table&&(f(_,["tbody"]),delete ct.tbody),t.TRUSTED_TYPES_POLICY){if(typeof t.TRUSTED_TYPES_POLICY.createHTML!="function")throw q('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof t.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw q('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const r=L;L=t.TRUSTED_TYPES_POLICY;try{$=K("")}catch(a){throw L=r,a}}else t.TRUSTED_TYPES_POLICY===null?(L=void 0,$=""):(L===void 0&&(L=Ke()),L&&typeof $=="string"&&($=K("")));(A.uponSanitizeElement.length>0||A.uponSanitizeAttribute.length>0)&&_===Mt&&(_=I(_)),A.uponSanitizeAttribute.length>0&&h===Ct&&(h=I(h)),b&&b(t),tt=t},ye=f({},[...qt,...Kt,...Gn]),Se=f({},[...Zt,...Bn]),mn=function(t,e,r){return e.namespaceURI===k?t==="svg":e.namespaceURI===yt?t==="svg"&&(r==="annotation-xml"||Bt[r]):!!ye[t]},dn=function(t,e,r){return e.namespaceURI===k?t==="math":e.namespaceURI===St?t==="math"&&Wt[r]:!!Se[t]},Tn=function(t,e,r){return e.namespaceURI===St&&!Wt[r]||e.namespaceURI===yt&&!Bt[r]?!1:!Se[t]&&(cn[t]||!ye[t])},_n=function(t){let e=st(t);(!e||!e.tagName)&&(e={namespaceURI:Q,tagName:"template"});const r=_t(t.tagName),a=_t(e.tagName);return Gt[t.namespaceURI]?t.namespaceURI===St?mn(r,e,a):t.namespaceURI===yt?dn(r,e,a):t.namespaceURI===k?Tn(r,e,a):!!(ft==="application/xhtml+xml"&&Gt[t.namespaceURI]):!1},B=function(t){nt(o.removed,{element:t});try{st(t).removeChild(t)}catch{if(ee(t),!st(t))throw q("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},be=function(t){const e=at(t);if(e){const a=[];mt(e,c=>{nt(a,c)}),mt(a,c=>{try{ee(c)}catch{}})}const r=Dt(t);if(r)for(let a=r.length-1;a>=0;--a){const c=r[a],p=c&&c.name;if(typeof p=="string")try{t.removeAttribute(p)}catch{}}},V=function(t,e){try{nt(o.removed,{attribute:e.getAttributeNode(t),from:e})}catch{nt(o.removed,{attribute:null,from:e})}if(e.removeAttribute(t),t==="is")if(Z||Et)try{B(e)}catch{}else try{e.setAttribute(t,"")}catch{}},hn=function(t){const e=Dt(t);if(e)for(let r=e.length-1;r>=0;--r){const a=e[r],c=a&&a.name;if(!(typeof c!="string"||h[T(c)]))try{t.removeAttribute(c)}catch{}}},gn=function(t){const e=[t];for(;e.length>0;){const r=e.pop();(M?M(r):r.nodeType)===v.element&&hn(r);const c=at(r);if(c)for(let p=c.length-1;p>=0;--p)e.push(c[p])}},Oe=function(t){let e=null,r=null;if(kt)t="<remove></remove>"+t;else{const p=Pe(t,/^[\r\n\t ]+/);r=p&&p[0]}ft==="application/xhtml+xml"&&Q===k&&(t='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+t+"</body></html>");const a=L?K(t):t;if(Q===k)try{e=new It().parseFromString(a,ft)}catch{}if(!e||!e.documentElement){e=wt.createDocument(Q,"template",null);try{e.documentElement.innerHTML=Ht?$:a}catch{}}const c=e.body||e.documentElement;return t&&r&&c.insertBefore(s.createTextNode(r),c.childNodes[0]||null),Q===k?Je.call(e,X?"html":"body")[0]:X?e.documentElement:c},Re=function(t){return ie.call(t.ownerDocument||t,t,w.SHOW_ELEMENT|w.SHOW_COMMENT|w.SHOW_TEXT|w.SHOW_PROCESSING_INSTRUCTION|w.SHOW_CDATA_SECTION,null)},bt=function(t){return t=dt(t,tn," "),t=dt(t,en," "),t=dt(t,nn," "),t},jt=function(t){var e;t.normalize();const r=ie.call(t.ownerDocument||t,t,w.SHOW_TEXT|w.SHOW_COMMENT|w.SHOW_CDATA_SECTION|w.SHOW_PROCESSING_INSTRUCTION,null);let a=r.nextNode();for(;a;)a.data=bt(a.data),a=r.nextNode();const c=(e=t.querySelectorAll)===null||e===void 0?void 0:e.call(t,"template");c&&mt(c,p=>{et(p.content)&&jt(p.content)})},Ot=function(t){const e=z?z(t):null;return typeof e!="string"||T(e)!=="form"?!1:typeof t.nodeName!="string"||typeof t.textContent!="string"||typeof t.removeChild!="function"||t.attributes!==Dt(t)||typeof t.removeAttribute!="function"||typeof t.setAttribute!="function"||typeof t.namespaceURI!="string"||typeof t.insertBefore!="function"||typeof t.hasChildNodes!="function"||t.nodeType!==M(t)||t.childNodes!==at(t)},et=function(t){if(!M||typeof t!="object"||t===null)return!1;try{return M(t)===v.documentFragment}catch{return!1}},pt=function(t){if(!M||typeof t!="object"||t===null)return!1;try{return typeof M(t)=="number"}catch{return!1}};function F(i,t,e){i.length!==0&&mt(i,r=>{r.call(o,t,e,tt)})}const En=function(t,e){return!!(ut&&t.hasChildNodes()&&!pt(t.firstElementChild)&&S(Be,t.textContent)&&S(Be,t.innerHTML)||ut&&t.namespaceURI===k&&e==="style"&&pt(t.firstElementChild)||t.nodeType===v.processingInstruction||ut&&t.nodeType===v.comment&&S(Jn,t.data))},An=function(t,e){if(!ct[e]&&De(e)&&(d.tagNameCheck instanceof RegExp&&S(d.tagNameCheck,e)||d.tagNameCheck instanceof Function&&d.tagNameCheck(e)))return!1;if(vt&&!x[e]){const r=st(t),a=at(t);if(a&&r){const c=a.length;for(let p=c-1;p>=0;--p){const y=Ut?a[p]:Xe(a[p],!0);r.insertBefore(y,Ve(t))}}}return B(t),!0},Ne=function(t){if(F(A.beforeSanitizeElements,t,null),Ot(t))return B(t),!0;const e=T(z?z(t):t.nodeName);if(F(A.uponSanitizeElement,t,{tagName:e,allowedTags:_}),En(t,e))return B(t),!0;if(ct[e]||!(H.tagCheck instanceof Function&&H.tagCheck(e))&&!_[e])return An(t,e);if((M?M(t):t.nodeType)===v.element&&!_n(t)||(e==="noscript"||e==="noembed"||e==="noframes")&&S(Qn,t.innerHTML))return B(t),!0;if(G&&t.nodeType===v.text){const a=bt(t.textContent);t.textContent!==a&&(nt(o.removed,{element:t.cloneNode()}),t.textContent=a)}return F(A.afterSanitizeElements,t,null),!1},Ie=function(t,e,r){if(le[e]||pe&&(e==="id"||e==="name")&&(r in s||r in pn))return!1;const a=h[e]||H.attributeCheck instanceof Function&&H.attributeCheck(e,t);if(!(Pt&&S(on,e))){if(!(ce&&S(rn,e))){if(a){if(!zt[e]){if(!S(se,dt(r,ae,""))){if(!((e==="src"||e==="xlink:href"||e==="href")&&t!=="script"&&xe(r,"data:")===0&&Te[t])){if(!(ue&&!S(an,dt(r,ae,"")))){if(r)return!1}}}}}else if(!(De(t)&&(d.tagNameCheck instanceof RegExp&&S(d.tagNameCheck,t)||d.tagNameCheck instanceof Function&&d.tagNameCheck(t))&&(d.attributeNameCheck instanceof RegExp&&S(d.attributeNameCheck,e)||d.attributeNameCheck instanceof Function&&d.attributeNameCheck(e,t))||e==="is"&&d.allowCustomizedBuiltInElements&&(d.tagNameCheck instanceof RegExp&&S(d.tagNameCheck,r)||d.tagNameCheck instanceof Function&&d.tagNameCheck(r))))return!1}}return!0},yn=f({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),De=function(t){return!yn[_t(t)]&&S(sn,t)},Sn=function(t,e,r,a){if(L&&typeof ht=="object"&&typeof ht.getAttributeType=="function"&&!r)switch(ht.getAttributeType(t,e)){case"TrustedHTML":return K(a);case"TrustedScriptURL":return qe(a)}return a},bn=function(t,e,r,a){try{r?t.setAttributeNS(r,e,a):t.setAttribute(e,a),Ot(t)?B(t):Ce(o.removed)}catch{V(e,t)}},Le=function(t){F(A.beforeSanitizeAttributes,t,null);const e=t.attributes;if(!e||Ot(t))return;const r={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:h,forceKeepAttr:void 0};let a=e.length;const c=T(t.nodeName);for(;a--;){const p=e[a],y=p.name,g=p.namespaceURI,C=p.value,P=T(y),Xt=C;let N=y==="value"?Xt:xn(Xt);if(r.attrName=P,r.attrValue=N,r.keepAttr=!0,r.forceKeepAttr=void 0,F(A.uponSanitizeAttribute,t,r),N=r.attrValue,me&&(P==="id"||P==="name")&&xe(N,de)!==0&&(V(y,t),N=de+N),ut&&S(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,N)){V(y,t);continue}if(P==="attributename"&&Pe(N,"href")){V(y,t);continue}if(!r.forceKeepAttr){if(!r.keepAttr){V(y,t);continue}if(!fe&&S(to,N)){V(y,t);continue}if(G&&(N=bt(N)),!Ie(c,P,N)){V(y,t);continue}N=Sn(c,P,g,N),N!==Xt&&bn(t,y,g,N)}}F(A.afterSanitizeAttributes,t,null)},Rt=function(t){let e=null;const r=Re(t);for(F(A.beforeSanitizeShadowDOM,t,null);e=r.nextNode();)if(F(A.uponSanitizeShadowNode,e,null),Ne(e),Le(e),et(e.content)&&Rt(e.content),(M?M(e):e.nodeType)===v.element){const c=ne(e);et(c)&&($t(c),Rt(c))}F(A.afterSanitizeShadowDOM,t,null)},$t=function(t){const e=[{node:t,shadow:null}];for(;e.length>0;){const r=e.pop();if(r.shadow){Rt(r.shadow);continue}const a=r.node,p=(M?M(a):a.nodeType)===v.element,y=at(a);if(y)for(let g=y.length-1;g>=0;--g)e.push({node:y[g],shadow:null});if(p){const g=z?z(a):null;if(typeof g=="string"&&T(g)==="template"){const C=a.content;et(C)&&e.push({node:C,shadow:null})}}if(p){const g=ne(a);et(g)&&e.push({node:null,shadow:g},{node:g,shadow:null})}}};return o.sanitize=function(i){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},e=null,r=null,a=null,c=null;if(Ht=!i,Ht&&(i="<!-->"),typeof i!="string"&&!pt(i)&&(i=zn(i),typeof i!="string"))throw q("dirty is not a string, aborting");if(!o.isSupported)return i;xt||Yt(t),o.removed=[];const p=Ut&&typeof i!="string"&&pt(i);if(p){const C=z?z(i):i.nodeName;if(typeof C=="string"){const P=T(C);if(!_[P]||ct[P])throw q("root node is forbidden and cannot be sanitized in-place")}if(Ot(i))throw q("root node is clobbered and cannot be sanitized in-place");try{$t(i)}catch(P){throw be(i),P}}else if(pt(i))e=Oe("<!---->"),r=e.ownerDocument.importNode(i,!0),r.nodeType===v.element&&r.nodeName==="BODY"||r.nodeName==="HTML"?e=r:e.appendChild(r),$t(r);else{if(!Z&&!G&&!X&&i.indexOf("<")===-1)return L&&At?K(i):i;if(e=Oe(i),!e)return Z?null:At?$:""}e&&kt&&B(e.firstChild);const y=Re(p?i:e);try{for(;a=y.nextNode();)Ne(a),Le(a),et(a.content)&&Rt(a.content)}catch(C){throw p&&be(i),C}if(p)return mt(o.removed,C=>{C.element&&gn(C.element)}),G&&jt(i),i;if(Z){if(G&&jt(e),Et)for(c=Ze.call(e.ownerDocument);e.firstChild;)c.appendChild(e.firstChild);else c=e;return(h.shadowroot||h.shadowrootmode)&&(c=Qe.call(l,c,!0)),c}let g=X?e.outerHTML:e.innerHTML;return X&&_["!doctype"]&&e.ownerDocument&&e.ownerDocument.doctype&&e.ownerDocument.doctype.name&&S(Kn,e.ownerDocument.doctype.name)&&(g="<!DOCTYPE "+e.ownerDocument.doctype.name+`>
|
|
`+g),G&&(g=bt(g)),L&&At?K(g):g},o.setConfig=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Yt(i),xt=!0},o.clearConfig=function(){tt=null,xt=!1,L=Lt,$=""},o.isValidAttribute=function(i,t,e){tt||Yt({});const r=T(i),a=T(t);return Ie(r,a,e)},o.addHook=function(i,t){typeof t=="function"&&nt(A[i],t)},o.removeHook=function(i,t){if(t!==void 0){const e=Cn(A[i],t);return e===-1?void 0:Pn(A[i],e,1)[0]}return Ce(A[i])},o.removeHooks=function(i){A[i]=[]},o.removeAllHooks=function(){A=We()},o}var oo=$e();export{oo as p};
|