corrade-nucleus-nucleons – Blame information for rev 4

Subversion Repositories:
Rev:
Rev Author Line No. Line
2 office 1 //
2 // Unpacker warning: be careful when using myobfuscate.com for your projects:
3 // scripts obfuscated by the free online version call back home.
4 //
5  
6 //
7 // Unpacker for Dean Edward's p.a.c.k.e.r, a part of javascript beautifier
8 // written by Einar Lielmanis <einar@jsbeautifier.org>
9 //
10 // Coincidentally, it can defeat a couple of other eval-based compressors.
11 //
12 // usage:
13 //
14 // if (P_A_C_K_E_R.detect(some_string)) {
15 // var unpacked = P_A_C_K_E_R.unpack(some_string);
16 // }
17 //
18 //
19  
20 var P_A_C_K_E_R = {
21 detect: function (str) {
22 return P_A_C_K_E_R._starts_with(str.toLowerCase().replace(/ +/g, ''), 'eval(function(') ||
23 P_A_C_K_E_R._starts_with(str.toLowerCase().replace(/ +/g, ''), 'eval((function(') ;
24 },
25  
26 unpack: function (str) {
27 var unpacked_source = '';
28 if (P_A_C_K_E_R.detect(str)) {
29 try {
30 eval('unpacked_source = ' + str.substring(4) + ';')
31 if (typeof unpacked_source == 'string' && unpacked_source) {
32 str = unpacked_source;
33 }
34 } catch (error) {
35 // well, it failed. we'll just return the original, instead of crashing on user.
36 }
37 }
38 return str;
39 },
40  
41 _starts_with: function (str, what) {
42 return str.substr(0, what.length) === what;
43 },
44  
45 run_tests: function (sanity_test) {
46 var t = sanity_test || new SanityTest();
47 t.test_function(P_A_C_K_E_R.detect, "P_A_C_K_E_R.detect");
48 t.expect('', false);
49 t.expect('var a = b', false);
50 t.expect('eval(function(p,a,c,k,e,r', true);
51 t.expect('eval ( function(p, a, c, k, e, r', true);
52  
53 t.test_function(P_A_C_K_E_R.unpack, 'P_A_C_K_E_R.unpack');
54 t.expect("eval(function(p,a,c,k,e,r){e=String;if(!''.replace(/^/,String)){while(c--)r[c]=k[c]||c;k=[function(e){return r[e]}];e=function(){return'\\\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\\\b'+e(c)+'\\\\b','g'),k[c]);return p}('0 2=1',3,3,'var||a'.split('|'),0,{}))",
55 'var a=1');
56  
57 var starts_with_a = function(what) { return P_A_C_K_E_R._starts_with(what, 'a'); }
58 t.test_function(starts_with_a, "P_A_C_K_E_R._starts_with(?, a)");
59 t.expect('abc', true);
60 t.expect('bcd', false);
61 t.expect('a', true);
62 t.expect('', false);
63 return t;
64 }
65 }