paradoxxxzero_butterfly/butterfly/static/html-sanitizer.js

2 lines
21 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var html4={};html4.atype={NONE:0,URI:1,URI_FRAGMENT:11,SCRIPT:2,STYLE:3,ID:4,IDREF:5,IDREFS:6,GLOBAL_NAME:7,LOCAL_NAME:8,CLASSES:9,FRAME_TARGET:10},html4.ATTRIBS={"*::class":9,"*::dir":0,"*::id":4,"*::lang":0,"*::onclick":2,"*::ondblclick":2,"*::onkeydown":2,"*::onkeypress":2,"*::onkeyup":2,"*::onload":2,"*::onmousedown":2,"*::onmousemove":2,"*::onmouseout":2,"*::onmouseover":2,"*::onmouseup":2,"*::style":3,"*::title":0,"a::accesskey":0,"a::coords":0,"a::href":1,"a::hreflang":0,"a::name":7,"a::onblur":2,"a::onfocus":2,"a::rel":0,"a::rev":0,"a::shape":0,"a::tabindex":0,"a::target":10,"a::type":0,"area::accesskey":0,"area::alt":0,"area::coords":0,"area::href":1,"area::nohref":0,"area::onblur":2,"area::onfocus":2,"area::shape":0,"area::tabindex":0,"area::target":10,"bdo::dir":0,"blockquote::cite":1,"br::clear":0,"button::accesskey":0,"button::disabled":0,"button::name":8,"button::onblur":2,"button::onfocus":2,"button::tabindex":0,"button::type":0,"button::value":0,"caption::align":0,"col::align":0,"col::char":0,"col::charoff":0,"col::span":0,"col::valign":0,"col::width":0,"colgroup::align":0,"colgroup::char":0,"colgroup::charoff":0,"colgroup::span":0,"colgroup::valign":0,"colgroup::width":0,"del::cite":1,"del::datetime":0,"dir::compact":0,"div::align":0,"dl::compact":0,"font::color":0,"font::face":0,"font::size":0,"form::accept":0,"form::action":1,"form::autocomplete":0,"form::enctype":0,"form::method":0,"form::name":7,"form::onreset":2,"form::onsubmit":2,"form::target":10,"h1::align":0,"h2::align":0,"h3::align":0,"h4::align":0,"h5::align":0,"h6::align":0,"hr::align":0,"hr::noshade":0,"hr::size":0,"hr::width":0,"iframe::align":0,"iframe::frameborder":0,"iframe::height":0,"iframe::marginheight":0,"iframe::marginwidth":0,"iframe::width":0,"img::align":0,"img::alt":0,"img::border":0,"img::height":0,"img::hspace":0,"img::ismap":0,"img::name":7,"img::src":1,"img::usemap":11,"img::vspace":0,"img::width":0,"input::accept":0,"input::accesskey":0,"input::align":0,"input::alt":0,"input::autocomplete":0,"input::checked":0,"input::disabled":0,"input::ismap":0,"input::maxlength":0,"input::name":8,"input::onblur":2,"input::onchange":2,"input::onfocus":2,"input::onselect":2,"input::readonly":0,"input::size":0,"input::src":1,"input::tabindex":0,"input::type":0,"input::usemap":11,"input::value":0,"ins::cite":1,"ins::datetime":0,"label::accesskey":0,"label::for":5,"label::onblur":2,"label::onfocus":2,"legend::accesskey":0,"legend::align":0,"li::type":0,"li::value":0,"map::name":7,"menu::compact":0,"ol::compact":0,"ol::start":0,"ol::type":0,"optgroup::disabled":0,"optgroup::label":0,"option::disabled":0,"option::label":0,"option::selected":0,"option::value":0,"p::align":0,"pre::width":0,"q::cite":1,"select::disabled":0,"select::multiple":0,"select::name":8,"select::onblur":2,"select::onchange":2,"select::onfocus":2,"select::size":0,"select::tabindex":0,"table::align":0,"table::bgcolor":0,"table::border":0,"table::cellpadding":0,"table::cellspacing":0,"table::frame":0,"table::rules":0,"table::summary":0,"table::width":0,"tbody::align":0,"tbody::char":0,"tbody::charoff":0,"tbody::valign":0,"td::abbr":0,"td::align":0,"td::axis":0,"td::bgcolor":0,"td::char":0,"td::charoff":0,"td::colspan":0,"td::headers":6,"td::height":0,"td::nowrap":0,"td::rowspan":0,"td::scope":0,"td::valign":0,"td::width":0,"textarea::accesskey":0,"textarea::cols":0,"textarea::disabled":0,"textarea::name":8,"textarea::onblur":2,"textarea::onchange":2,"textarea::onfocus":2,"textarea::onselect":2,"textarea::readonly":0,"textarea::rows":0,"textarea::tabindex":0,"tfoot::align":0,"tfoot::char":0,"tfoot::charoff":0,"tfoot::valign":0,"th::abbr":0,"th::align":0,"th::axis":0,"th::bgcolor":0,"th::char":0,"th::charoff":0,"th::colspan":0,"th::headers":6,"th::height":0,"th::nowrap":0,"th::rowspan":0,"th::scope":0,"th::valign":0,"th::width":0,"thead::align":0,"thead::char":0,"thead::charoff":0,"thead::valign":0,"tr::align":0,"tr::bgcolor":0,"tr::char":0,"tr::charoff":0,"tr::valign":0,"ul::compact":0,"ul::type":0},html4.eflags={OPTIONAL_ENDTAG:1,EMPTY:2,CDATA:4,RCDATA:8,UNSAFE:16,FOLDABLE:32,SCRIPT:64,STYLE:128},html4.ELEMENTS={a:0,abbr:0,acronym:0,address:0,applet:16,area:2,b:0,base:18,basefont:18,bdo:0,big:0,blockquote:0,body:49,br:2,button:0,caption:0,center:0,cite:0,code:0,col:2,colgroup:1,dd:1,del:0,dfn:0,dir:0,div:0,dl:0,dt:1,em:0,fieldset:0,font:0,form:0,frame:18,frameset:16,h1:0,h2:0,h3:0,h4:0,h5:0,h6:0,head:49,hr:2,html:49,i:0,iframe:4,img:2,input:2,ins:0,isindex:18,kbd:0,label:0,legend:0,li:1,link:18,map:0,menu:0,meta:18,noframes:20,noscript:20,object:16,ol:0,optgroup:0,option:1,p:1,param:18,pre:0,q:0,s:0,samp:0,script:84,select:0,small:0,span:0,strike:0,strong:0,style:148,sub:0,sup:0,table:0,tbody:1,td:1,textarea:8,tfoot:1,th:1,thead:1,title:24,tr:1,tt:0,u:0,ul:0,"var":0},html4.URIEFFECTS={},html4.LOADERTYPES={},"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=html4),exports.URI=html4):"undefined"!=typeof window&&(window.html4=html4);var URI=function(){function t(t){var e=(""+t).match(f);return e?new l(c(e[1]),c(e[2]),c(e[3]),c(e[4]),c(e[5]),c(e[6]),c(e[7])):null}function e(t,e,o,i,s,c,h){var u=new l(r(t,m),r(e,m),a(o),i>0?i.toString():null,r(s,d),null,a(h));return c&&("string"==typeof c?u.setRawQuery(c.replace(/[^?&=0-9A-Za-z_\-~.%]/g,n)):u.setAllParameters(c)),u}function a(t){return"string"==typeof t?encodeURIComponent(t):null}function r(t,e){return"string"==typeof t?encodeURI(t).replace(e,n):null}function n(t){var e=t.charCodeAt(0);return"%"+"0123456789ABCDEF".charAt(e>>4&15)+"0123456789ABCDEF".charAt(15&e)}function o(t){return t.replace(/(^|\/)\.(?:\/|$)/g,"$1").replace(/\/{2,}/g,"/")}function i(t){if(null===t)return null;for(var e,a=o(t),r=u;(e=a.replace(r,"$1"))!=a;a=e);return a}function s(t,e){var a=t.clone(),r=e.hasScheme();r?a.setRawScheme(e.getRawScheme()):r=e.hasCredentials(),r?a.setRawCredentials(e.getRawCredentials()):r=e.hasDomain(),r?a.setRawDomain(e.getRawDomain()):r=e.hasPort();var n=e.getRawPath(),o=i(n);if(r)a.setPort(e.getPort()),o=o&&o.replace(p,"");else if(r=!!n){if(47!==o.charCodeAt(0)){var s=i(a.getRawPath()||"").replace(p,""),l=s.lastIndexOf("/")+1;o=i((l?s.substring(0,l):"")+i(n)).replace(p,"")}}else o=o&&o.replace(p,""),o!==n&&a.setRawPath(o);return r?a.setRawPath(o):r=e.hasQuery(),r?a.setRawQuery(e.getRawQuery()):r=e.hasFragment(),r&&a.setRawFragment(e.getRawFragment()),a}function l(t,e,a,r,n,o,i){this.scheme_=t,this.credentials_=e,this.domain_=a,this.port_=r,this.path_=n,this.query_=o,this.fragment_=i,this.paramCache_=null}function c(t){return"string"==typeof t&&t.length>0?t:null}var h=new RegExp("(/|^)(?:[^./][^/]*|\\.{2,}(?:[^./][^/]*)|\\.{3,}[^/]*)/\\.\\.(?:/|$)"),u=new RegExp(h),p=/^(?:\.\.\/)*(?:\.\.$)?/;l.prototype.toString=function(){var t=[];return null!==this.scheme_&&t.push(this.scheme_,":"),null!==this.domain_&&(t.push("//"),null!==this.credentials_&&t.push(this.credentials_,"@"),t.push(this.domain_),null!==this.port_&&t.push(":",this.port_.toString())),null!==this.path_&&t.push(this.path_),null!==this.query_&&t.push("?",this.query_),null!==this.fragment_&&t.push("#",this.fragment_),t.join("")},l.prototype.clone=function(){return new l(this.scheme_,this.credentials_,this.domain_,this.port_,this.path_,this.query_,this.fragment_)},l.prototype.getScheme=function(){return this.scheme_&&decodeURIComponent(this.scheme_).toLowerCase()},l.prototype.getRawScheme=function(){return this.scheme_},l.prototype.setScheme=function(t){return this.scheme_=r(t,m),this},l.prototype.setRawScheme=function(t){return this.scheme_=t?t:null,this},l.prototype.hasScheme=function(){return null!==this.scheme_},l.prototype.getCredentials=function(){return this.credentials_&&decodeURIComponent(this.credentials_)},l.prototype.getRawCredentials=function(){return this.credentials_},l.prototype.setCredentials=function(t){return this.credentials_=r(t,m),this},l.prototype.setRawCredentials=function(t){return this.credentials_=t?t:null,this},l.prototype.hasCredentials=function(){return null!==this.credentials_},l.prototype.getDomain=function(){return this.domain_&&decodeURIComponent(this.domain_)},l.prototype.getRawDomain=function(){return this.domain_},l.prototype.setDomain=function(t){return this.setRawDomain(t&&encodeURIComponent(t))},l.prototype.setRawDomain=function(t){return this.domain_=t?t:null,this.setRawPath(this.path_)},l.prototype.hasDomain=function(){return null!==this.domain_},l.prototype.getPort=function(){return this.port_&&decodeURIComponent(this.port_)},l.prototype.setPort=function(t){if(t){if(t=Number(t),t!==(65535&t))throw new Error("Bad port number "+t);this.port_=""+t}else this.port_=null;return this},l.prototype.hasPort=function(){return null!==this.port_},l.prototype.getPath=function(){return this.path_&&decodeURIComponent(this.path_)},l.prototype.getRawPath=function(){return this.path_},l.prototype.setPath=function(t){return this.setRawPath(r(t,d))},l.prototype.setRawPath=function(t){return t?(t=String(t),this.path_=!this.domain_||/^\//.test(t)?t:"/"+t):this.path_=null,this},l.prototype.hasPath=function(){return null!==this.path_},l.prototype.getQuery=function(){return this.query_&&decodeURIComponent(this.query_).replace(/\+/g," ")},l.prototype.getRawQuery=function(){return this.query_},l.prototype.setQuery=function(t){return this.paramCache_=null,this.query_=a(t),this},l.prototype.setRawQuery=function(t){return this.paramCache_=null,this.query_=t?t:null,this},l.prototype.hasQuery=function(){return null!==this.query_},l.prototype.setAllParameters=function(t){if("object"==typeof t&&!(t instanceof Array)&&(t instanceof Object||"[object Array]"!==Object.prototype.toString.call(t))){var e=[],a=-1;for(var r in t){var n=t[r];"string"==typeof n&&(e[++a]=r,e[++a]=n)}t=e}this.paramCache_=null;for(var o=[],i="",s=0;s<t.length;){var r=t[s++],n=t[s++];o.push(i,encodeURIComponent(r.toString())),i="&",n&&o.push("=",encodeURIComponent(n.toString()))}return this.query_=o.join(""),this},l.prototype.checkParameterCache_=function(){if(!this.paramCache_){var t=this.query_;if(t){for(var e=t.split(/[&\?]/),a=[],r=-1,n=0;n<e.length;++n){var o=e[n].match(/^([^=]*)(?:=(.*))?$/);a[++r]=decodeURIComponent(o[1]).replace(/\+/g," "),a[++r]=decodeURIComponent(o[2]||"").replace(/\+/g," ")}this.paramCache_=a}else this.paramCache_=[]}},l.prototype.setParameterValues=function(t,e){"string"==typeof e&&(e=[e]),this.checkParameterCache_();for(var a=0,r=this.paramCache_,n=[],o=0;o<r.length;o+=2)t===r[o]?a<e.length&&n.push(t,e[a++]):n.push(r[o],r[o+1]);for(;a<e.length;)n.push(t,e[a++]);return this.setAllParameters(n),this},l.prototype.removeParameter=function(t){return this.setParameterValues(t,[])},l.prototype.getAllParameters=function(){return this.checkParameterCache_(),this.paramCache_.slice(0,this.paramCache_.length)},l.prototype.getParameterValues=function(t){this.checkParameterCache_();for(var e=[],a=0;a<this.paramCache_.length;a+=2)t===this.paramCache_[a]&&e.push(this.paramCache_[a+1]);return e},l.prototype.getParameterMap=function(){this.checkParameterCache_();for(var t={},e=0;e<this.paramCache_.length;e+=2){var a=this.paramCache_[e++],r=this.paramCache_[e++];a in t?t[a].push(r):t[a]=[r]}return t},l.prototype.getParameterValue=function(t){this.checkParameterCache_();for(var e=0;e<this.paramCache_.length;e+=2)if(t===this.paramCache_[e])return this.paramCache_[e+1];return null},l.prototype.getFragment=function(){return this.fragment_&&decodeURIComponent(this.fragment_)},l.prototype.getRawFragment=function(){return this.fragment_},l.prototype.setFragment=function(t){return this.fragment_=t?encodeURIComponent(t):null,this},l.prototype.setRawFragment=function(t){return this.fragment_=t?t:null,this},l.prototype.hasFragment=function(){return null!==this.fragment_};var f=new RegExp("^(?:([^:/?#]+):)?(?://(?:([^/?#]*)@)?([^/?#:@]*)(?::([0-9]+))?)?([^?#]+)?(?:\\?([^#]*))?(?:#(.*))?$"),m=/[#\/\?@]/g,d=/[\#\?]/g;return l.parse=t,l.create=e,l.resolve=s,l.collapse_dots=i,l.utils={mimeTypeOf:function(e){var a=t(e);return/\.html$/.test(a.getPath())?"text/html":"application/javascript"},resolve:function(e,a){return e?s(t(e),t(a)).toString():""+a}},l}();if("undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=URI),exports.URI=URI):"undefined"!=typeof window&&(window.URI=URI),"i"!=="I".toLowerCase())throw"I/i problem";var html=function(t){function e(t){if(k.hasOwnProperty(t))return k[t];var e=t.match(z);if(e)return String.fromCharCode(parseInt(e[1],10));if(e=t.match(D))return String.fromCharCode(parseInt(e[1],16));if(L&&I.test(t)){L.innerHTML="&"+t+";";var a=L.textContent;return k[t]=a,a}return"&"+t+";"}function a(t,a){return e(a)}function r(t){return t.replace(M,"")}function n(t){return t.replace(N,a)}function o(t){return(""+t).replace(U,"&amp;").replace($,"&lt;").replace(G,"&gt;").replace(q,"&#34;")}function i(t){return t.replace(F,"&amp;$1").replace($,"&lt;").replace(G,"&gt;")}function s(t){var e={cdata:t.cdata||t.cdata,comment:t.comment||t.comment,endDoc:t.endDoc||t.endDoc,endTag:t.endTag||t.endTag,pcdata:t.pcdata||t.pcdata,rcdata:t.rcdata||t.rcdata,startDoc:t.startDoc||t.startDoc,startTag:t.startTag||t.startTag};return function(t,a){return l(t,e,a)}}function l(t,e,a){var r=u(t),n={noMoreGT:!1,noMoreEndComments:!1};h(e,r,0,n,a)}function c(t,e,a,r,n){return function(){h(t,e,a,r,n)}}function h(e,a,r,n,o){try{e.startDoc&&0==r&&e.startDoc(o);for(var i,s,l,h=r,u=a.length;u>h;){var d=a[h++],g=a[h];switch(d){case"&":O.test(g)?(e.pcdata&&e.pcdata("&"+g,o,Q,c(e,a,h,n,o)),h++):e.pcdata&&e.pcdata("&amp;",o,Q,c(e,a,h,n,o));break;case"</":(i=/^([-\w:]+)[^\'\"]*/.exec(g))?i[0].length===g.length&&">"===a[h+1]?(h+=2,l=i[1].toLowerCase(),e.endTag&&e.endTag(l,o,Q,c(e,a,h,n,o))):h=p(a,h,e,o,Q,n):e.pcdata&&e.pcdata("&lt;/",o,Q,c(e,a,h,n,o));break;case"<":if(i=/^([-\w:]+)\s*\/?/.exec(g))if(i[0].length===g.length&&">"===a[h+1]){h+=2,l=i[1].toLowerCase(),e.startTag&&e.startTag(l,[],o,Q,c(e,a,h,n,o));var y=t.ELEMENTS[l];if(y&Y){var b={name:l,next:h,eflags:y};h=m(a,b,e,o,Q,n)}}else h=f(a,h,e,o,Q,n);else e.pcdata&&e.pcdata("&lt;",o,Q,c(e,a,h,n,o));break;case"<!--":if(!n.noMoreEndComments){for(s=h+1;u>s&&(">"!==a[s]||!/--$/.test(a[s-1]));s++);if(u>s){if(e.comment){var w=a.slice(h,s).join("");e.comment(w.substr(0,w.length-2),o,Q,c(e,a,s+1,n,o))}h=s+1}else n.noMoreEndComments=!0}n.noMoreEndComments&&e.pcdata&&e.pcdata("&lt;!--",o,Q,c(e,a,h,n,o));break;case"<!":if(/^\w/.test(g)){if(!n.noMoreGT){for(s=h+1;u>s&&">"!==a[s];s++);u>s?h=s+1:n.noMoreGT=!0}n.noMoreGT&&e.pcdata&&e.pcdata("&lt;!",o,Q,c(e,a,h,n,o))}else e.pcdata&&e.pcdata("&lt;!",o,Q,c(e,a,h,n,o));break;case"<?":if(!n.noMoreGT){for(s=h+1;u>s&&">"!==a[s];s++);u>s?h=s+1:n.noMoreGT=!0}n.noMoreGT&&e.pcdata&&e.pcdata("&lt;?",o,Q,c(e,a,h,n,o));break;case">":e.pcdata&&e.pcdata("&gt;",o,Q,c(e,a,h,n,o));break;case"":break;default:e.pcdata&&e.pcdata(d,o,Q,c(e,a,h,n,o))}}e.endDoc&&e.endDoc(o)}catch(_){if(_!==Q)throw _}}function u(t){var e=/(<\/|<\!--|<[!?]|[&<>])/g;if(t+="",B)return t.split(e);for(var a,r=[],n=0;null!==(a=e.exec(t));)r.push(t.substring(n,a.index)),r.push(a[0]),n=a.index+a[0].length;return r.push(t.substring(n)),r}function p(t,e,a,r,n,o){var i=d(t,e);return i?(a.endTag&&a.endTag(i.name,r,n,c(a,t,e,o,r)),i.next):t.length}function f(t,e,a,r,n,o){var i=d(t,e);return i?(a.startTag&&a.startTag(i.name,i.attrs,r,n,c(a,t,i.next,o,r)),i.eflags&Y?m(t,i,a,r,n,o):i.next):t.length}function m(e,a,r,n,o,s){var l=e.length;V.hasOwnProperty(a.name)||(V[a.name]=new RegExp("^"+a.name+"(?:[\\s\\/]|$)","i"));for(var h=V[a.name],u=a.next,p=a.next+1;l>p&&("</"!==e[p-1]||!h.test(e[p]));p++);l>p&&(p-=1);var f=e.slice(u,p).join("");if(a.eflags&t.eflags.CDATA)r.cdata&&r.cdata(f,n,o,c(r,e,p,s,n));else{if(!(a.eflags&t.eflags.RCDATA))throw new Error("bug");r.rcdata&&r.rcdata(i(f),n,o,c(r,e,p,s,n))}return p}function d(e,a){var r=/^([-\w:]+)/.exec(e[a]),n={};n.name=r[1].toLowerCase(),n.eflags=t.ELEMENTS[n.name];for(var o=e[a].substr(r[0].length),i=a+1,s=e.length;s>i&&">"!==e[i];i++)o+=e[i];if(i>=s)return void 0;for(var l=[];""!==o;)if(r=j.exec(o)){if(r[4]&&!r[5]||r[6]&&!r[7]){for(var c=r[4]||r[6],h=!1,u=[o,e[i++]];s>i;i++){if(h){if(">"===e[i])break}else 0<=e[i].indexOf(c)&&(h=!0);u.push(e[i])}if(i>=s)break;o=u.join("");continue}var p=r[1].toLowerCase(),f=r[2]?g(r[3]):"";l.push(p,f),o=o.substr(r[0].length)}else o=o.replace(/^[\s\S][^a-z\s]*/,"");return n.attrs=l,n.next=i+1,n}function g(t){var e=t.charCodeAt(0);return(34===e||39===e)&&(t=t.substr(1,t.length-2)),n(r(t))}function y(e){var a,r,n=function(t,e){r||e.push(t)};return s({startDoc:function(){a=[],r=!1},startTag:function(n,i,s){if(!r&&t.ELEMENTS.hasOwnProperty(n)){var l=t.ELEMENTS[n];if(!(l&t.eflags.FOLDABLE)){var c=e(n,i);if(!c)return void(r=!(l&t.eflags.EMPTY));if("object"!=typeof c)throw new Error("tagPolicy did not return object (old API?)");if(!("attribs"in c))throw new Error("tagPolicy gave no attribs");i=c.attribs;var h,u;if("tagName"in c?(u=c.tagName,h=t.ELEMENTS[u]):(u=n,h=l),l&t.eflags.OPTIONAL_ENDTAG){var p=a[a.length-1];!p||p.orig!==n||p.rep===u&&n===u||s.push("</",p.rep,">")}l&t.eflags.EMPTY||a.push({orig:n,rep:u}),s.push("<",u);for(var f=0,m=i.length;m>f;f+=2){var d=i[f],g=i[f+1];null!==g&&void 0!==g&&s.push(" ",d,'="',o(g),'"')}s.push(">"),l&t.eflags.EMPTY&&!(h&t.eflags.EMPTY)&&s.push("</",u,">")}}},endTag:function(e,n){if(r)return void(r=!1);if(t.ELEMENTS.hasOwnProperty(e)){var o=t.ELEMENTS[e];if(!(o&(t.eflags.EMPTY|t.eflags.FOLDABLE))){var i;if(o&t.eflags.OPTIONAL_ENDTAG)for(i=a.length;--i>=0;){var s=a[i].orig;if(s===e)break;if(!(t.ELEMENTS[s]&t.eflags.OPTIONAL_ENDTAG))return}else for(i=a.length;--i>=0&&a[i].orig!==e;);if(0>i)return;for(var l=a.length;--l>i;){var c=a[l].rep;t.ELEMENTS[c]&t.eflags.OPTIONAL_ENDTAG||n.push("</",c,">")}i<a.length&&(e=a[i].rep),a.length=i,n.push("</",e,">")}}},pcdata:n,rcdata:n,cdata:n,endDoc:function(t){for(;a.length;a.length--)t.push("</",a[a.length-1].rep,">")}})}function b(t,e,a,r,n){if(!n)return null;try{var o=URI.parse(""+t);if(o&&(!o.hasScheme()||H.test(o.getScheme()))){var i=n(o,e,a,r);return i?i.toString():null}}catch(s){return null}return null}function w(t,e,a,r,n){if(a||t(e+" removed",{change:"removed",tagName:e}),r!==n){var o="changed";r&&!n?o="removed":!r&&n&&(o="added"),t(e+"."+a+" "+o,{change:o,tagName:e,attribName:a,oldValue:r,newValue:n})}}function _(t,e,a){var r;return r=e+"::"+a,t.hasOwnProperty(r)?t[r]:(r="*::"+a,t.hasOwnProperty(r)?t[r]:void 0)}function v(e,a){return _(t.LOADERTYPES,e,a)}function E(e,a){return _(t.URIEFFECTS,e,a)}function C(e,a,r,n,o){for(var i=0;i<a.length;i+=2){var s,l=a[i],c=a[i+1],h=c,u=null;if(s=e+"::"+l,(t.ATTRIBS.hasOwnProperty(s)||(s="*::"+l,t.ATTRIBS.hasOwnProperty(s)))&&(u=t.ATTRIBS[s]),null!==u)switch(u){case t.atype.NONE:break;case t.atype.SCRIPT:c=null,o&&w(o,e,l,h,c);break;case t.atype.STYLE:if("undefined"==typeof A){c=null,o&&w(o,e,l,h,c);break}var p=[];A(c,{declaration:function(e,a){var n=e.toLowerCase();P(n,a,r?function(e){return b(e,t.ueffects.SAME_DOCUMENT,t.ltypes.SANDBOXED,{TYPE:"CSS",CSS_PROP:n},r)}:null),a.length&&p.push(n+": "+a.join(" "))}}),c=p.length>0?p.join(" ; "):null,o&&w(o,e,l,h,c);break;case t.atype.ID:case t.atype.IDREF:case t.atype.IDREFS:case t.atype.GLOBAL_NAME:case t.atype.LOCAL_NAME:case t.atype.CLASSES:c=n?n(c):c,o&&w(o,e,l,h,c);break;case t.atype.URI:c=b(c,E(e,l),v(e,l),{TYPE:"MARKUP",XML_ATTR:l,XML_TAG:e},r),o&&w(o,e,l,h,c);break;case t.atype.URI_FRAGMENT:c&&"#"===c.charAt(0)?(c=c.substring(1),c=n?n(c):c,null!==c&&void 0!==c&&(c="#"+c)):c=null,o&&w(o,e,l,h,c);break;default:c=null,o&&w(o,e,l,h,c)}else c=null,o&&w(o,e,l,h,c);a[i+1]=c}return a}function T(e,a,r){return function(n,o){return t.ELEMENTS[n]&t.eflags.UNSAFE?void(r&&w(r,n,void 0,void 0,void 0)):{attribs:C(n,o,e,a,r)}}}function R(t,e){var a=[];return y(e)(t,a),a.join("")}function S(t,e,a,r){var n=T(e,a,r);return R(t,n)}var A,P,x;"undefined"!=typeof window&&(A=window.parseCssDeclarations,P=window.sanitizeCssProperty,x=window.cssSchema);var k={lt:"<",LT:"<",gt:">",GT:">",amp:"&",AMP:"&",quot:'"',apos:"'",nbsp:" "},z=/^#(\d+)$/,D=/^#x([0-9A-Fa-f]+)$/,I=/^[A-Za-z][A-za-z0-9]+$/,L="undefined"!=typeof window&&window.document?window.document.createElement("textarea"):null,M=/\0/g,N=/&(#[0-9]+|#[xX][0-9A-Fa-f]+|\w+);/g,O=/^(#[0-9]+|#[xX][0-9A-Fa-f]+|\w+);/,U=/&/g,F=/&([^a-z#]|#(?:[^0-9x]|x(?:[^0-9a-f]|$)|$)|$)/gi,$=/[<]/g,G=/>/g,q=/\"/g,j=new RegExp("^\\s*([-.:\\w]+)(?:\\s*(=)\\s*((\")[^\"]*(\"|$)|(')[^']*('|$)|(?=[a-z][-\\w]*\\s*=)|[^\"'\\s]*))?","i"),B=3==="a,b".split(/(,)/).length,Y=t.eflags.CDATA|t.eflags.RCDATA,Q={},V={},H=/^(?:https?|mailto)$/i,X={};return X.escapeAttrib=X.escapeAttrib=o,X.makeHtmlSanitizer=X.makeHtmlSanitizer=y,X.makeSaxParser=X.makeSaxParser=s,X.makeTagPolicy=X.makeTagPolicy=T,X.normalizeRCData=X.normalizeRCData=i,X.sanitize=X.sanitize=S,X.sanitizeAttribs=X.sanitizeAttribs=C,X.sanitizeWithPolicy=X.sanitizeWithPolicy=R,X.unescapeEntities=X.unescapeEntities=n,X}(html4),html_sanitize=html.sanitize;"undefined"!=typeof window&&(window.html=html,window.html_sanitize=html_sanitize);var Sanitizer={};Sanitizer.escapeAttrib=html.escapeAttrib,Sanitizer.makeHtmlSanitizer=html.makeHtmlSanitizer,Sanitizer.makeSaxParser=html.makeSaxParser,Sanitizer.makeTagPolicy=html.makeTagPolicy,Sanitizer.normalizeRCData=html.normalizeRCData,Sanitizer.sanitizeAttribs=html.sanitizeAttribs,Sanitizer.sanitizeWithPolicy=html.sanitizeWithPolicy,Sanitizer.unescapeEntities=html.unescapeEntities,Sanitizer.escape=html.escapeAttrib,Sanitizer.sanitize=function(t,e,a,r){return"string"==typeof t&&(t=t.replace(/<([a-zA-Z]+)([^>]*)\/>/g,"<$1$2></$1>")),html.sanitize(t,e,a,r)},"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=Sanitizer),exports.Sanitizer=Sanitizer):this.Sanitizer=Sanitizer;