Skip Menu |

This queue is for tickets about the JavaScript-Beautifier CPAN distribution.

Report information
The Basics
Id: 125117
Status: resolved
Priority: 0/
Queue: JavaScript-Beautifier

People
Owner: Nobody in particular
Requestors: eleonora45 [...] gmx.net
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Beautifier.pm, Packer1.pm
Date: Wed, 18 Apr 2018 22:25:57 +0200
To: bug-JavaScript-Beautifier [...] rt.cpan.org
From: "eleonora45 [...] gmx.net" <eleonora45 [...] gmx.net>
Hello, There is a java script packer: http://dean.edwards.name/packer/ That is used to obfuscate tables in web pages. There was a javascript and python de-obfuscator, now I ported it to perl. http://jsbeautifier.org/ The perl module is Packer1.pm, I added to this mail. It has to be bound by two lines of code to Beautifier.pm: use JavaScript::Packer1 qw/js_packer/; and $js_source_code = js_packer($js_source_code); Packer1.pm must be located also in directory JavaScript. The last test in 01-javascript-beauty.t handles the packer code. I believe, the modification I suggested earlier, is no good. (  #$js_source_code =~ s/\\/\\\\/g;  # prevent \\ -> \  tktk) I commented it out. Please read this: https://stackoverflow.com/questions/16168763/preserving-backslashes-in-perl-strings I now modified the usage description: ---------------------------------------------------------------------- =head1 FUNCTIONS $js_source_code = <<EOF   a = 12;   {return '\\w+';} EOF =head2 js_beautify( $js_source_code, $opts ); beautify javascript. ----------------------------------------------------------------------- With this I suggest the user to use the EOF mechanism to create the string. Using the EOF mechanism or reading the javascript data from a file, there is no need to add backslashes to the string. I found this out, because the packer part failed to work, if we use additional backslashes. Thank you in advance for adding packer to the perl javascript beautifier.

Message body is not shown because sender requested not to inline it.

Message body is not shown because sender requested not to inline it.

Message body is not shown because sender requested not to inline it.

hi, thanks for the work but I typed x=2;eval(function(p,a,c,k,e,d){e=function(c){return c.toString(36)};if(!''.replace(/^/,String)){while(c--){d[c.toString(a)]=k[c]||c.toString(a)}k=[function(e){return d[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}('$(5).4(3(){$(\'.1\').0(2);$(\'.6\').0(d);$(\'.7\').0(b);$(\'.a\').0(8);$(\'.9\').0(c)});',14,14,'html|r5e57|8080|function|ready|document|r1655|rc15b|8888|r39b0|r6ae9|3128|65309|80'.split('|'),0,{}))c=abx; in http://jsbeautifier.org/ it's not unpacked? do you know any idea why? thanks
Subject: Re: [rt.cpan.org #125117] Beautifier.pm, Packer1.pm
Date: Thu, 19 Apr 2018 07:45:41 +0200
To: bug-JavaScript-Beautifier [...] rt.cpan.org
From: "eleonora45 [...] gmx.net" <eleonora45 [...] gmx.net>
Try this: eval(function(p,a,c,k,e,d){e=function(c){return c.toString(36)};if(!''.replace(/^/,String)){while(c--){d[c.toString(a)]=k[c]||c.toString(a)}k=[function(e){return d[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}('$(5).4(3(){$(\'.1\').0(2);$(\'.6\').0(d);$(\'.7\').0(b);$(\'.a\').0(8);$(\'.9\').0(c)});',14,14,'html|r5e57|8080|function|ready|document|r1655|rc15b|8888|r39b0|r6ae9|3128|65309|80'.split('|'),0,{})) The javascript and also the python version have problems, if there is javascript code before or after the packed code. https://github.com/beautify-web/js-beautify/issues/1376 The perl code handles these cases well. Thanks for caring this. 2018-04-19 02:07 keltezéssel, Fayland Lin via RT írta: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=125117 > > > hi, thanks for the work > > but I typed > > x=2;eval(function(p,a,c,k,e,d){e=function(c){return c.toString(36)};if(!''.replace(/^/,String)){while(c--){d[c.toString(a)]=k[c]||c.toString(a)}k=[function(e){return d[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}('$(5).4(3(){$(\'.1\').0(2);$(\'.6\').0(d);$(\'.7\').0(b);$(\'.a\').0(8);$(\'.9\').0(c)});',14,14,'html|r5e57|8080|function|ready|document|r1655|rc15b|8888|r39b0|r6ae9|3128|65309|80'.split('|'),0,{}))c=abx; > > in http://jsbeautifier.org/ > > it's not unpacked? do you know any idea why? > > thanks
hi I removed debug line, and make a perltidy then uploaded it to PAUSE. thanks for your work.
Subject: Re: [rt.cpan.org #125117] Resolved: Beautifier.pm, Packer1.pm
Date: Thu, 19 Apr 2018 08:09:17 +0200
To: bug-JavaScript-Beautifier [...] rt.cpan.org
From: "eleonora45 [...] gmx.net" <eleonora45 [...] gmx.net>
Thanks a million! 2018-04-19 08:07 keltezéssel, Fayland Lin via RT írta: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=125117 > > > According to our records, your request has been resolved. If you have any > further questions or concerns, please respond to this message.
Subject: Re: [rt.cpan.org #125117] Resolved: Beautifier.pm, Packer1.pm
Date: Sat, 21 Apr 2018 18:26:12 +0200
To: bug-JavaScript-Beautifier [...] rt.cpan.org
From: "eleonora45 [...] gmx.net" <eleonora45 [...] gmx.net>
Hello, I have found a case, packer did not handle well. I updated Packer1.pm accordingly. It is now smaller, simpler and better, version 0.20. I also added this case to the tests, it is test #280. Thanks in advance for updateing cpan. This is the added test case: eval(function(p,a,c,k,e,d){e=function(c){return c.toString(36)};if(!''.replace(/^/,String)){while(c--){d[c.toString(a)]=k[c]||c.toString(a)}k=[function(e){return d[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}('2 0="4 3!";2 1=0.5(/b/6);a.9("8").7=1;',12,12,'str|n|var|W3Schools|Visit|search|i|innerHTML|demo|getElementById|document|w3Schools'.split('|'),0,{}))

Message body is not shown because sender requested not to inline it.

Message body is not shown because sender requested not to inline it.

0.24 shipped. thanks
Subject: Re: [rt.cpan.org #125117] 01-javascript-beauty.t
Date: Wed, 25 Apr 2018 07:08:41 +0200
To: bug-JavaScript-Beautifier [...] rt.cpan.org
From: "eleonora45 [...] gmx.net" <eleonora45 [...] gmx.net>
Hi, I fixed the test. In the previous version I added sub test_beautifier1 that added a "\n" to the result. I considered that solution as not nice. Now I found a better solution: I use chomp on the expected pattern. That eliminates the need for sub test_beautifier1 Thanks in advance to add this to the official JavaScript beautifier.

Message body is not shown because sender requested not to inline it.

https://github.com/fayland/perl-javascript-beautifier/commit/8c2aff3bac99dec6e5e69a2d58ef37762a177215 I do not do another release since it's just a test chance. thanks for your help.
Subject: Re: [rt.cpan.org #125117] 01-javascript-beauty.t
Date: Wed, 2 May 2018 12:59:55 +0200
To: bug-JavaScript-Beautifier [...] rt.cpan.org
From: "eleonora45 [...] gmx.net" <eleonora45 [...] gmx.net>
Hi, I found an other case, that did not work. I made now the logic more stable and robust. Also added this case to the tests. Thank you in advance for putting this version into cpan. FYI: I am looking for cases, that fail to work with the python version, fix it, and if it fails with perl, I also fix it. That is the motivation for tests and fixes.

Message body is not shown because sender requested not to inline it.

Message body is not shown because sender requested not to inline it.

uploaded. thanks
Subject: Re: [rt.cpan.org #125117] 01-javascript-beauty.t
Date: Thu, 3 May 2018 12:06:15 +0200
To: bug-JavaScript-Beautifier [...] rt.cpan.org
From: "eleonora45 [...] gmx.net" <eleonora45 [...] gmx.net>
Hi, Re-worked Packer1.pm, because of a new case. Added this case to the tests. Did complete retest. Thanks in advance for adding this to the main line.

Message body is not shown because sender requested not to inline it.

Message body is not shown because sender requested not to inline it.

Subject: Re: [rt.cpan.org #125117] 01-javascript-beauty.t
Date: Thu, 03 May 2018 16:24:01 +0000
To: bug-JavaScript-Beautifier [...] rt.cpan.org
From: JJ Merelo <jjmerelo [...] gmail.com>
You probably use GitHub, could you do this through a pull request?
Subject: Re: [rt.cpan.org #125117] 01-javascript-beauty.t
Date: Thu, 3 May 2018 22:19:00 +0200
To: bug-JavaScript-Beautifier [...] rt.cpan.org
From: "eleonora45 [...] gmx.net" <eleonora45 [...] gmx.net>
Filed a Pull request in GitHub (user swan46) Please inform me, when accepted Thank you. 2018-05-03 18:24 keltezéssel, jjmerelo@gmail.com via RT írta: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=125117 > > > You probably use GitHub, could you do this through a pull request? >
merged. will do a release if you don't have more changes on Monday. :) thanks