forked from YahooArchive/secure-handlebars-helpers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsecure-handlebars-helpers.min.js
5 lines (5 loc) · 3.82 KB
/
secure-handlebars-helpers.min.js
1
2
3
4
5
/**
* secure-handlebars-helpers - v1.0.7
* Yahoo! Inc. Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
*/
!function(){var a=function(){function a(a){return a=a.split(w,2),2===a.length&&a[0]?a[0]:null}function b(a,b){return"undefined"==typeof a?"undefined":null===a?"null":b.apply(a.toString(),[].splice.call(arguments,2))}function c(a,c,d,e){c=c||p,d=d||o;var f,h=[].splice.call(arguments,4);return b(a,function(){return f=this.replace(k,"�").replace(d,function(a,b,d,e){return b?(b=Number(b[0]<="9"?b:"0"+b),128===b?"€":130===b?"‚":131===b?"ƒ":132===b?"„":133===b?"…":134===b?"†":135===b?"‡":136===b?"ˆ":137===b?"‰":138===b?"Š":139===b?"‹":140===b?"Œ":142===b?"Ž":145===b?"‘":146===b?"’":147===b?"“":148===b?"”":149===b?"•":150===b?"–":151===b?"—":152===b?"˜":153===b?"™":154===b?"š":155===b?"›":156===b?"œ":158===b?"ž":159===b?"Ÿ":b>=55296&&57343>=b||13===b?"�":g.frCoPt(b)):c[d||e]||a}),e?e.apply(f,h):f})}function d(a){return"\\"+a.charCodeAt(0).toString(16).toLowerCase()+" "}function e(a,b){return c(a,null,null,function(){return this.replace(b,d)})}function f(b,e){return c(b,null,null,function(){var b=g.yufull(this),c=a(b);return b=c&&v[c.toLowerCase()]?"##"+b:b,e?b.replace(e,d):b})}var g,h=/</g,i=/"/g,j=/'/g,k=/\x00/g,l=/(?:^(?:["'`]|\x00+$|$)|[\x09-\x0D >])/g,m=/[&<>"'`]/g,n=/(?:\x00|^-*!?>|--!?>|--?!?$|\]>|\]$)/g,o=/&(?:#([xX][0-9A-Fa-f]+|\d+);?|(Tab|NewLine|colon|semi|lpar|rpar|apos|sol|comma|excl|ast|midast|ensp|emsp|thinsp);|(nbsp|amp|AMP|lt|LT|gt|GT|quot|QUOT);?)/g,p={Tab:" ",NewLine:"\n",colon:":",semi:";",lpar:"(",rpar:")",apos:"'",sol:"/",comma:",",excl:"!",ast:"*",midast:"*",ensp:" ",emsp:" ",thinsp:" ",nbsp:" ",amp:"&",lt:"<",gt:">",quot:'"',QUOT:'"'},q=/[^%#+\-\w\.]/g,r=/[\x01-\x1F\x7F\\"]/g,s=/[\x01-\x1F\x7F\\']/g,t=/['\(\)]/g,u=/\/\/%5[Bb]([A-Fa-f0-9:]+)%5[Dd]/,v={javascript:1,data:1,vbscript:1,mhtml:1},w=/(?::|&#[xX]0*3[aA];?|�*58;?|:)/,x=/(?:^[\x00-\x20]+|[\t\n\r\x00]+)/g,y={Tab:" ",NewLine:"\n"},z=String.prototype.replace,A=String.fromCodePoint||function(a){return 0===arguments.length?"":65535>=a?String.fromCharCode(a):(a-=65536,String.fromCharCode((a>>10)+55296,a%1024+56320))};return g={frCoPt:function(a){return!isFinite(a)||0>=a||a>1114111||a>=1&&8>=a||a>=14&&31>=a||a>=127&&159>=a||a>=64976&&65007>=a||11===a||65535===(65535&a)||65534===(65535&a)?"�":A(a)},d:c,yup:function(b){return b=a(b.replace(k,"")),b?c(b,y,null,function(){return this.replace(x,"").toLowerCase()}):null},y:function(a){return b(a,z,m,function(a){return"&"===a?"&":"<"===a?"<":">"===a?">":'"'===a?""":"'"===a?"'":"`"})},yd:function(a){return b(a,z,h,"<")},yc:function(a){return b(a,z,n,function(a){return"\x00"===a?"�":"--!"===a||"--"===a||"-"===a||"]"===a?a+" ":a.slice(0,-1)+" >"})},yavd:function(a){return b(a,z,i,""")},yavs:function(a){return b(a,z,j,"'")},yavu:function(a){return b(a,z,l,function(a){return" "===a?"	":"\n"===a?" ":""===a?"":"\f"===a?"":"\r"===a?" ":" "===a?" ":">"===a?">":'"'===a?""":"'"===a?"'":"`"===a?"`":"�"})},yu:encodeURI,yuc:encodeURIComponent,yubl:function(a){return v[g.yup(a)]?"x-"+a:a},yufull:function(a){return g.yu(a).replace(u,function(a,b){return"//["+b+"]"})},yceu:function(a){return e(a,q)},yced:function(a){return e(a,r)},yces:function(a){return e(a,s)},yceuu:function(a){return f(a,t)},yceud:function(a){return f(a)},yceus:function(a){return f(a,j)}}}();!function(b,c,d,e){function f(b){return function(c){return c&&c.toHTML?c:a[b](c)}}if(!b||!b.registerHelper||!b.Utils.escapeExpression)throw new ReferenceError("Handlebars is not defined");for(b.registerHelper("y",b.Utils.escapeExpression);e=c[d];d++)b.registerHelper(e,f(e))}(Handlebars,["yd","yc","yavd","yavs","yavu","yu","yuc","yubl","yufull","yceu","yced","yces","yceuu","yceud","yceus"],0)}();