Created
July 9, 2012 20:41
-
-
Save DasRed/3078762 to your computer and use it in GitHub Desktop.
Opery JS Crypt Bug with whitespace fix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<title>Opery JS Crypt Bug</title> | |
<script type="text/javascript" src="./mootools.compressed.flatten.js"></script> | |
<script type="text/javascript"> | |
function runTest(elementId, output) | |
{ | |
var TEST = new Class( | |
{ | |
Implements: Options, | |
initialize: function() | |
{ | |
this.setOptions(); | |
}, | |
toString: function() | |
{ | |
return this.parsed.value; | |
} | |
}); | |
try | |
{ | |
var test = new TEST(); | |
} | |
catch (e) | |
{ | |
document.getElementById(elementId).innerHTML = output + '<span style="color:#C00000">failed with ' + e.message + '<br />' + e.stack + '<br /><br/>' + e.stacktrace + '</style>'; | |
return; | |
} | |
document.getElementById(elementId).innerHTML = output + '<span style="color:#00A000">success</style>'; | |
} | |
</script> | |
</head> | |
<body> | |
<div id="output1"></div> | |
<script type="text/javascript"> | |
// this compressed code does NOT failed | |
Class.Mutators.initialize=function(a){return function(){Array.from(this.Binds).each(function(b){var c=this[b];if(c){this[b]=c.bind(this)}},this);return a.apply(this, arguments)}}; | |
runTest('output1', 'test 1: '); | |
</script> | |
<div id="output2"></div> | |
<script type="text/javascript"> | |
// this compressed code failed | |
Class.Mutators.initialize=function(a){return function(){Array.from(this.Binds).each(function(b){var c=this[b];if(c){this[b]=c.bind(this)}},this);return a.apply(this,arguments)}}; | |
runTest('output2', 'test 2: '); | |
</script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){this.MooTools={version:"1.4.4",build:"adb02e676407521b516ffa10d2dc6b54237a80f9"};var o=this.typeOf=function(i){if(i==null){return"null"}if(i.$family!=null){return i.$family()}if(i.nodeName){if(i.nodeType==1){return"element"}if(i.nodeType==3){return(/\S/).test(i.nodeValue)?"textnode":"whitespace"}}else{if(typeof i.length=="number"){if(i.callee){return"arguments"}if("item" in i){return"collection"}}}return typeof i};var j=this.instanceOf=function(u,i){if(u==null){return false}var t=u.$constructor||u.constructor;while(t){if(t===i){return true}t=t.parent}if(!u.hasOwnProperty){return false}return u instanceof i};var f=this.Function;var q=true;for(var k in {toString:1}){q=null}if(q){q=["hasOwnProperty","valueOf","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","constructor"]}f.prototype.overloadSetter=function(t){var i=this;return function(v,u){if(v==null){return this}if(t||typeof v!="string"){for(var w in v){i.call(this,w,v[w])}if(q){for(var x=q.length;x--;){w=q[x]; | |
if(v.hasOwnProperty(w)){i.call(this,w,v[w])}}}}else{i.call(this,v,u)}return this}};f.prototype.overloadGetter=function(t){var i=this;return function(v){var w,u;if(t||typeof v!="string"){w=v}else{if(arguments.length>1){w=arguments}}if(w){u={};for(var x=0;x<w.length;x++){u[w[x]]=i.call(this,w[x])}}else{u=i.call(this,v)}return u}};f.prototype.extend=function(i,t){this[i]=t}.overloadSetter();f.prototype.implement=function(i,t){this.prototype[i]=t}.overloadSetter();var n=Array.prototype.slice;f.from=function(i){return(o(i)=="function")?i:function(){return i}};Array.from=function(i){if(i==null){return[]}return(a.isEnumerable(i)&&typeof i!="string")?(o(i)=="array")?i:n.call(i):[i]};Number.from=function(t){var i=parseFloat(t);return isFinite(i)?i:null};String.from=function(i){return i+""};f.implement({hide:function(){this.$hidden=true;return this},protect:function(){this.$protected=true;return this}});var a=this.Type=function(v,u){if(v){var t=v.toLowerCase();var i=function(w){return(o(w)==t)};a["is"+v]=i; | |
if(u!=null){u.prototype.$family=(function(){return t}).hide()}}if(u==null){return null}u.extend(this);u.$constructor=a;u.prototype.$constructor=u;return u};var e=Object.prototype.toString;a.isEnumerable=function(i){return(i!=null&&typeof i.length=="number"&&e.call(i)!="[object Function]")};var r={};var s=function(i){var t=o(i.prototype);return r[t]||(r[t]=[])};var b=function(u,y){if(y&&y.$hidden){return}var t=s(this);for(var v=0;v<t.length;v++){var x=t[v];if(o(x)=="type"){b.call(x,u,y)}else{x.call(this,u,y)}}var w=this.prototype[u];if(w==null||!w.$protected){this.prototype[u]=y}if(this[u]==null&&o(y)=="function"){m.call(this,u,function(i){return y.apply(i,n.call(arguments,1))})}};var m=function(i,u){if(u&&u.$hidden){return}var t=this[i];if(t==null||!t.$protected){this[i]=u}};a.implement({implement:b.overloadSetter(),extend:m.overloadSetter(),alias:function(i,t){b.call(this,i,this.prototype[t])}.overloadSetter(),mirror:function(i){s(this).push(i);return this}});new a("Type",a);var d=function(t,y,w){var v=(y!=Object),C=y.prototype; | |
if(v){y=new a(t,y)}for(var z=0,x=w.length;z<x;z++){var D=w[z],B=y[D],A=C[D];if(B){B.protect()}if(v&&A){y.implement(D,A.protect())}}if(v){var u=C.propertyIsEnumerable(w[0]);y.forEachMethod=function(H){if(!u){for(var G=0,E=w.length;G<E;G++){H.call(C,C[w[G]],w[G])}}for(var F in C){H.call(C,C[F],F)}}}return d};d("String",String,["charAt","charCodeAt","concat","indexOf","lastIndexOf","match","quote","replace","search","slice","split","substr","substring","trim","toLowerCase","toUpperCase"])("Array",Array,["pop","push","reverse","shift","sort","splice","unshift","concat","join","slice","indexOf","lastIndexOf","filter","forEach","every","map","some","reduce","reduceRight"])("Number",Number,["toExponential","toFixed","toLocaleString","toPrecision"])("Function",f,["apply","call","bind"])("RegExp",RegExp,["exec","test"])("Object",Object,["create","defineProperty","defineProperties","keys","getPrototypeOf","getOwnPropertyDescriptor","getOwnPropertyNames","preventExtensions","isExtensible","seal","isSealed","freeze","isFrozen"])("Date",Date,["now"]); | |
Object.extend=m.overloadSetter();Date.extend("now",function(){return +(new Date)});new a("Boolean",Boolean);Number.prototype.$family=function(){return isFinite(this)?"number":"null"}.hide();Number.extend("random",function(t,i){return Math.floor(Math.random()*(i-t+1)+t)});var g=Object.prototype.hasOwnProperty;Object.extend("forEach",function(i,u,v){for(var t in i){if(g.call(i,t)){u.call(v,i[t],t,i)}}});Object.each=Object.forEach;Array.implement({forEach:function(v,w){for(var u=0,t=this.length;u<t;u++){if(u in this){v.call(w,this[u],u,this)}}},each:function(i,t){Array.forEach(this,i,t);return this}});var l=function(i){switch(o(i)){case"array":return i.clone();case"object":return Object.clone(i);default:return i}};Array.implement("clone",function(){var t=this.length,u=new Array(t);while(t--){u[t]=l(this[t])}return u});var h=function(t,i,u){switch(o(u)){case"object":if(o(t[i])=="object"){Object.merge(t[i],u)}else{t[i]=Object.clone(u)}break;case"array":t[i]=u.clone();break;default:t[i]=u}return t | |
};Object.extend({merge:function(A,w,u){if(o(w)=="string"){return h(A,w,u)}for(var z=1,t=arguments.length;z<t;z++){var x=arguments[z];for(var y in x){h(A,y,x[y])}}return A},clone:function(i){var u={};for(var t in i){u[t]=l(i[t])}return u},append:function(x){for(var w=1,u=arguments.length;w<u;w++){var t=arguments[w]||{};for(var v in t){x[v]=t[v]}}return x}});["Object","WhiteSpace","TextNode","Collection","Arguments"].each(function(i){new a(i)});var c=Date.now();String.extend("uniqueID",function(){return(c++).toString(36)})})();Array.implement({every:function(c,d){for(var b=0,a=this.length>>>0;b<a;b++){if((b in this)&&!c.call(d,this[b],b,this)){return false}}return true},filter:function(d,f){var c=[];for(var e,b=0,a=this.length>>>0;b<a;b++){if(b in this){e=this[b];if(d.call(f,e,b,this)){c.push(e)}}}return c},indexOf:function(c,d){var b=this.length>>>0;for(var a=(d<0)?Math.max(0,b+d):d||0;a<b;a++){if(this[a]===c){return a}}return -1},map:function(c,e){var d=this.length>>>0,b=Array(d);for(var a=0; | |
a<d;a++){if(a in this){b[a]=c.call(e,this[a],a,this)}}return b},some:function(c,d){for(var b=0,a=this.length>>>0;b<a;b++){if((b in this)&&c.call(d,this[b],b,this)){return true}}return false},clean:function(){return this.filter(function(a){return a!=null})},invoke:function(a){var b=Array.slice(arguments,1);return this.map(function(c){return c[a].apply(c,b)})},associate:function(c){var d={},b=Math.min(this.length,c.length);for(var a=0;a<b;a++){d[c[a]]=this[a]}return d},link:function(c){var a={};for(var e=0,b=this.length;e<b;e++){for(var d in c){if(c[d](this[e])){a[d]=this[e];delete c[d];break}}}return a},contains:function(a,b){return this.indexOf(a,b)!=-1},append:function(a){this.push.apply(this,a);return this},getLast:function(){return(this.length)?this[this.length-1]:null},getRandom:function(){return(this.length)?this[Number.random(0,this.length-1)]:null},include:function(a){if(!this.contains(a)){this.push(a)}return this},combine:function(c){for(var b=0,a=c.length;b<a;b++){this.include(c[b]) | |
}return this},erase:function(b){for(var a=this.length;a--;){if(this[a]===b){this.splice(a,1)}}return this},empty:function(){this.length=0;return this},flatten:function(){var d=[];for(var b=0,a=this.length;b<a;b++){var c=typeOf(this[b]);if(c=="null"){continue}d=d.concat((c=="array"||c=="collection"||c=="arguments"||instanceOf(this[b],Array))?Array.flatten(this[b]):this[b])}return d},pick:function(){for(var b=0,a=this.length;b<a;b++){if(this[b]!=null){return this[b]}}return null},hexToRgb:function(b){if(this.length!=3){return null}var a=this.map(function(c){if(c.length==1){c+=c}return c.toInt(16)});return(b)?a:"rgb("+a+")"},rgbToHex:function(d){if(this.length<3){return null}if(this.length==4&&this[3]==0&&!d){return"transparent"}var b=[];for(var a=0;a<3;a++){var c=(this[a]-0).toString(16);b.push((c.length==1)?"0"+c:c)}return(d)?b:"#"+b.join("")}});String.implement({test:function(a,b){return((typeOf(a)=="regexp")?a:new RegExp(""+a,b)).test(this)},contains:function(a,b){return(b)?(b+this+b).indexOf(b+a+b)>-1:String(this).indexOf(a)>-1 | |
},trim:function(){return String(this).replace(/^\s+|\s+$/g,"")},clean:function(){return String(this).replace(/\s+/g," ").trim()},camelCase:function(){return String(this).replace(/-\D/g,function(a){return a.charAt(1).toUpperCase()})},hyphenate:function(){return String(this).replace(/[A-Z]/g,function(a){return("-"+a.charAt(0).toLowerCase())})},capitalize:function(){return String(this).replace(/\b[a-z]/g,function(a){return a.toUpperCase()})},escapeRegExp:function(){return String(this).replace(/([-.*+?^${}()|[\]\/\\])/g,"\\$1")},toInt:function(a){return parseInt(this,a||10)},toFloat:function(){return parseFloat(this)},hexToRgb:function(b){var a=String(this).match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/);return(a)?a.slice(1).hexToRgb(b):null},rgbToHex:function(b){var a=String(this).match(/\d{1,3}/g);return(a)?a.rgbToHex(b):null},substitute:function(a,b){return String(this).replace(b||(/\\?\{([^{}]+)\}/g),function(d,c){if(d.charAt(0)=="\\"){return d.slice(1)}return(a[c]!=null)?a[c]:""})}});Number.implement({limit:function(b,a){return Math.min(a,Math.max(b,this)) | |
},round:function(a){a=Math.pow(10,a||0).toFixed(a<0?-a:0);return Math.round(this*a)/a},times:function(b,c){for(var a=0;a<this;a++){b.call(c,a,this)}},toFloat:function(){return parseFloat(this)},toInt:function(a){return parseInt(this,a||10)}});Number.alias("each","times");(function(b){var a={};b.each(function(c){if(!Number[c]){a[c]=function(){return Math[c].apply(null,[this].concat(Array.from(arguments)))}}});Number.implement(a)})(["abs","acos","asin","atan","atan2","ceil","cos","exp","floor","log","max","min","pow","sin","sqrt","tan"]);Function.extend({attempt:function(){for(var b=0,a=arguments.length;b<a;b++){try{return arguments[b]()}catch(c){}}return null}});Function.implement({attempt:function(a,c){try{return this.apply(c,Array.from(a))}catch(b){}return null},bind:function(e){var a=this,b=arguments.length>1?Array.slice(arguments,1):null,d=function(){};var c=function(){var g=e,h=arguments.length;if(this instanceof c){d.prototype=a.prototype;g=new d}var f=(!b&&!h)?a.call(g):a.apply(g,b&&h?b.concat(Array.slice(arguments)):b||arguments);return g==e?f:g};return c},pass:function(b,c){var a=this;if(b!=null){b=Array.from(b)}return function(){return a.apply(c,b||arguments)}},delay:function(b,c,a){return setTimeout(this.pass((a==null?[]:a),c),b)},periodical:function(c,b,a){return setInterval(this.pass((a==null?[]:a),b),c)}});(function(){var a=Object.prototype.hasOwnProperty;Object.extend({subset:function(d,g){var f={};for(var e=0,b=g.length;e<b;e++){var c=g[e];if(c in d){f[c]=d[c]}}return f},map:function(b,e,f){var d={};for(var c in b){if(a.call(b,c)){d[c]=e.call(f,b[c],c,b)}}return d},filter:function(b,e,g){var d={};for(var c in b){var f=b[c];if(a.call(b,c)&&e.call(g,f,c,b)){d[c]=f}}return d},every:function(b,d,e){for(var c in b){if(a.call(b,c)&&!d.call(e,b[c],c)){return false}}return true},some:function(b,d,e){for(var c in b){if(a.call(b,c)&&d.call(e,b[c],c)){return true}}return false},keys:function(b){var d=[];for(var c in b){if(a.call(b,c)){d.push(c)}}return d},values:function(c){var b=[];for(var d in c){if(a.call(c,d)){b.push(c[d]) | |
}}return b},getLength:function(b){return Object.keys(b).length},keyOf:function(b,d){for(var c in b){if(a.call(b,c)&&b[c]===d){return c}}return null},contains:function(b,c){return Object.keyOf(b,c)!=null},toQueryString:function(b,c){var d=[];Object.each(b,function(h,g){if(c){g=c+"["+g+"]"}var f;switch(typeOf(h)){case"object":f=Object.toQueryString(h,g);break;case"array":var e={};h.each(function(k,j){e[j]=k});f=Object.toQueryString(e,g);break;default:f=g+"="+encodeURIComponent(h)}if(h!=null){d.push(f)}});return d.join("&")}})})();(function(){var a=this.Class=new Type("Class",function(h){if(instanceOf(h,Function)){h={initialize:h}}var g=function(){e(this);if(g.$prototyping){return this}this.$caller=null;var i=(this.initialize)?this.initialize.apply(this,arguments):this;this.$caller=this.caller=null;return i}.extend(this).implement(h);g.$constructor=a;g.prototype.$constructor=g;g.prototype.parent=c;return g});var c=function(){if(!this.$caller){throw new Error('The method "parent" cannot be called.')}var g=this.$caller.$name,h=this.$caller.$owner.parent,i=(h)?h.prototype[g]:null;if(!i){throw new Error('The method "'+g+'" has no parent.')}return i.apply(this,arguments)};var e=function(g){for(var h in g){var j=g[h];switch(typeOf(j)){case"object":var i=function(){}; | |
i.prototype=j;g[h]=e(new i);break;case"array":g[h]=j.clone();break}}return g};var b=function(g,h,j){if(j.$origin){j=j.$origin}var i=function(){if(j.$protected&&this.$caller==null){throw new Error('The method "'+h+'" cannot be called.')}var l=this.caller,m=this.$caller;this.caller=m;this.$caller=i;var k=j.apply(this,arguments);this.$caller=m;this.caller=l;return k}.extend({$owner:g,$origin:j,$name:h});return i};var f=function(h,i,g){if(a.Mutators.hasOwnProperty(h)){i=a.Mutators[h].call(this,i);if(i==null){return this}}if(typeOf(i)=="function"){if(i.$hidden){return this}this.prototype[h]=(g)?i:b(this,h,i)}else{Object.merge(this.prototype,h,i)}return this};var d=function(g){g.$prototyping=true;var h=new g;delete g.$prototyping;return h};a.implement("implement",f.overloadSetter());a.Mutators={Extends:function(g){this.parent=g;this.prototype=d(g)},Implements:function(g){Array.from(g).each(function(j){var h=new j;for(var i in h){f.call(this,i,h[i],true)}},this)}}})();(function(){this.Chain=new Class({$chain:[],chain:function(){this.$chain.append(Array.flatten(arguments)); | |
return this},callChain:function(){return(this.$chain.length)?this.$chain.shift().apply(this,arguments):false},clearChain:function(){this.$chain.empty();return this}});var a=function(b){return b.replace(/^on([A-Z])/,function(c,d){return d.toLowerCase()})};this.Events=new Class({$events:{},addEvent:function(d,c,b){d=a(d);this.$events[d]=(this.$events[d]||[]).include(c);if(b){c.internal=true}return this},addEvents:function(b){for(var c in b){this.addEvent(c,b[c])}return this},fireEvent:function(e,c,b){e=a(e);var d=this.$events[e];if(!d){return this}c=Array.from(c);d.each(function(f){if(b){f.delay(b,this,c)}else{f.apply(this,c)}},this);return this},removeEvent:function(e,d){e=a(e);var c=this.$events[e];if(c&&!d.internal){var b=c.indexOf(d);if(b!=-1){delete c[b]}}return this},removeEvents:function(d){var e;if(typeOf(d)=="object"){for(e in d){this.removeEvent(e,d[e])}return this}if(d){d=a(d)}for(e in this.$events){if(d&&d!=e){continue}var c=this.$events[e];for(var b=c.length;b--;){if(b in c){this.removeEvent(e,c[b]) | |
}}}return this}});this.Options=new Class({setOptions:function(){var b=this.options=Object.merge.apply(null,[{},this.options].append(arguments));if(this.addEvent){for(var c in b){if(typeOf(b[c])!="function"||!(/^on[A-Z]/).test(c)){continue}this.addEvent(c,b[c]);delete b[c]}}return this}})})(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment