angular-sanitize.min.js 5.7 KB

1
  1. !function(e,t){"use strict";function n(e){var n=[];return s(n,t.noop).chars(e),n.join("")}function r(e,n){var r,i={},a=e.split(",");for(r=0;r<a.length;r++)i[n?t.lowercase(a[r]):a[r]]=!0;return i}function i(t,n){null===t||void 0===t?t="":"string"!=typeof t&&(t=""+t),c.innerHTML=t;var r=5;do{if(0===r)throw d("uinput","Failed to sanitize html because the input is unstable");r--,e.document.documentMode&&l(c),t=c.innerHTML,c.innerHTML=t}while(t!==c.innerHTML);for(var i=c.firstChild;i;){switch(i.nodeType){case 1:n.start(i.nodeName.toLowerCase(),a(i.attributes));break;case 3:n.chars(i.textContent)}var o;if(!((o=i.firstChild)||(1==i.nodeType&&n.end(i.nodeName.toLowerCase()),o=i.nextSibling)))for(;null==o&&(i=i.parentNode)!==c;)o=i.nextSibling,1==i.nodeType&&n.end(i.nodeName.toLowerCase());i=o}for(;i=c.firstChild;)c.removeChild(i)}function a(e){for(var t={},n=0,r=e.length;n<r;n++){var i=e[n];t[i.name]=i.value}return t}function o(e){return e.replace(/&/g,"&amp;").replace(u,function(e){return"&#"+(1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320)+65536)+";"}).replace(h,function(e){return"&#"+e.charCodeAt(0)+";"}).replace(/</g,"&lt;").replace(/>/g,"&gt;")}function s(e,n){var r=!1,i=t.bind(e,e.push);return{start:function(e,a){e=t.lowercase(e),!r&&y[e]&&(r=e),r||!0!==k[e]||(i("<"),i(e),t.forEach(a,function(r,a){var s=t.lowercase(a),l="img"===e&&"src"===s||"background"===s;!0!==z[s]||!0===w[s]&&!n(r,l)||(i(" "),i(a),i('="'),i(o(r)),i('"'))}),i(">"))},end:function(e){e=t.lowercase(e),r||!0!==k[e]||!0===p[e]||(i("</"),i(e),i(">")),e==r&&(r=!1)},chars:function(e){r||i(o(e))}}}function l(t){if(t.nodeType===e.Node.ELEMENT_NODE)for(var n=t.attributes,r=0,i=n.length;r<i;r++){var a=n[r],o=a.name.toLowerCase();"xmlns:ns1"!==o&&0!==o.lastIndexOf("ns1:",0)||(t.removeAttributeNode(a),r--,i--)}var s=t.firstChild;s&&l(s),(s=t.nextSibling)&&l(s)}var c,d=t.$$minErr("$sanitize"),u=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,h=/([^\#-~ |!])/g,p=r("area,br,col,hr,img,wbr"),f=r("colgroup,dd,dt,li,p,tbody,td,tfoot,th,thead,tr"),m=r("rp,rt"),g=t.extend({},m,f),b=t.extend({},f,r("address,article,aside,blockquote,caption,center,del,dir,div,dl,figure,figcaption,footer,h1,h2,h3,h4,h5,h6,header,hgroup,hr,ins,map,menu,nav,ol,pre,section,table,ul")),v=t.extend({},m,r("a,abbr,acronym,b,bdi,bdo,big,br,cite,code,del,dfn,em,font,i,img,ins,kbd,label,map,mark,q,ruby,rp,rt,s,samp,small,span,strike,strong,sub,sup,time,tt,u,var")),x=r("circle,defs,desc,ellipse,font-face,font-face-name,font-face-src,g,glyph,hkern,image,linearGradient,line,marker,metadata,missing-glyph,mpath,path,polygon,polyline,radialGradient,rect,stop,svg,switch,text,title,tspan"),y=r("script,style"),k=t.extend({},p,b,v,g),w=r("background,cite,href,longdesc,src,xlink:href"),C=r("abbr,align,alt,axis,bgcolor,border,cellpadding,cellspacing,class,clear,color,cols,colspan,compact,coords,dir,face,headers,height,hreflang,hspace,ismap,lang,language,nohref,nowrap,rel,rev,rows,rowspan,rules,scope,scrolling,shape,size,span,start,summary,tabindex,target,title,type,valign,value,vspace,width"),E=r("accent-height,accumulate,additive,alphabetic,arabic-form,ascent,baseProfile,bbox,begin,by,calcMode,cap-height,class,color,color-rendering,content,cx,cy,d,dx,dy,descent,display,dur,end,fill,fill-rule,font-family,font-size,font-stretch,font-style,font-variant,font-weight,from,fx,fy,g1,g2,glyph-name,gradientUnits,hanging,height,horiz-adv-x,horiz-origin-x,ideographic,k,keyPoints,keySplines,keyTimes,lang,marker-end,marker-mid,marker-start,markerHeight,markerUnits,markerWidth,mathematical,max,min,offset,opacity,orient,origin,overline-position,overline-thickness,panose-1,path,pathLength,points,preserveAspectRatio,r,refX,refY,repeatCount,repeatDur,requiredExtensions,requiredFeatures,restart,rotate,rx,ry,slope,stemh,stemv,stop-color,stop-opacity,strikethrough-position,strikethrough-thickness,stroke,stroke-dasharray,stroke-dashoffset,stroke-linecap,stroke-linejoin,stroke-miterlimit,stroke-opacity,stroke-width,systemLanguage,target,text-anchor,to,transform,type,u1,u2,underline-position,underline-thickness,unicode,unicode-range,units-per-em,values,version,viewBox,visibility,width,widths,x,x-height,x1,x2,xlink:actuate,xlink:arcrole,xlink:role,xlink:show,xlink:title,xlink:type,xml:base,xml:lang,xml:space,xmlns,xmlns:xlink,y,y1,y2,zoomAndPan",!0),z=t.extend({},w,E,C);!function(e){var t;if(!e.document||!e.document.implementation)throw d("noinert","Can't create an inert html document");var n=((t=e.document.implementation.createHTMLDocument("inert")).documentElement||t.getDocumentElement()).getElementsByTagName("body");if(1===n.length)c=n[0];else{var r=t.createElement("html");c=t.createElement("body"),r.appendChild(c),t.appendChild(r)}}(e),t.module("ngSanitize",[]).provider("$sanitize",function(){var e=!1;this.$get=["$$sanitizeUri",function(n){return e&&t.extend(k,x),function(e){var t=[];return i(e,s(t,function(e,t){return!/^unsafe:/.test(n(e,t))})),t.join("")}}],this.enableSvg=function(n){return t.isDefined(n)?(e=n,this):e}}),t.module("ngSanitize").filter("linky",["$sanitize",function(e){var r=/((ftp|https?):\/\/|(www\.)|(mailto:)?[A-Za-z0-9._%+-]+@)\S*[^\s.;,(){}<>"\u201d\u2019]/i,i=/^mailto:/i,a=t.$$minErr("linky"),o=t.isString;return function(s,l,c){function d(e){e&&m.push(n(e))}if(null==s||""===s)return s;if(!o(s))throw a("notstring","Expected string but received: {0}",s);for(var u,h,p,f=s,m=[];u=f.match(r);)h=u[0],u[2]||u[4]||(h=(u[3]?"http://":"mailto:")+h),p=u.index,d(f.substr(0,p)),function(e,n){var r;if(m.push("<a "),t.isFunction(c)&&(c=c(e)),t.isObject(c))for(r in c)m.push(r+'="'+c[r]+'" ');else c={};!t.isDefined(l)||"target"in c||m.push('target="',l,'" '),m.push('href="',e.replace(/"/g,"&quot;"),'">'),d(n),m.push("</a>")}(h,u[0].replace(i,"")),f=f.substring(p+u[0].length);return d(f),e(m.join(""))}}])}(window,window.angular);