[libjavascript-packer-perl] 01/01: Fix FTBS due to random order of returned keys (Closes: #711629)

dod at debian.org dod at debian.org
Thu Oct 9 11:46:15 UTC 2014


This is an automated email from the git hooks/post-receive script.

dod pushed a commit to branch master
in repository libjavascript-packer-perl.

commit f863cdbdc014aff2dc389a2d5015e42bfeb398d5
Author: Dominique Dumont <dod at debian.org>
Date:   Thu Oct 9 13:44:37 2014 +0200

    Fix FTBS due to random order of returned keys (Closes: #711629)
---
 debian/patches/fix-random-var-name-issue | 112 +++++++++++++++++++++++++++++++
 debian/patches/series                    |   1 +
 2 files changed, 113 insertions(+)

diff --git a/debian/patches/fix-random-var-name-issue b/debian/patches/fix-random-var-name-issue
new file mode 100644
index 0000000..9489550
--- /dev/null
+++ b/debian/patches/fix-random-var-name-issue
@@ -0,0 +1,112 @@
+Description: Fix random var name issue
+ Test failures were due to randomisation of keys %foo.
+ .
+ A sort was added to all calls to keys. The tests were
+ modified to suit the now ordered keys results.
+Bug: https://github.com/nevesenin/javascript-packer-perl/issues/8
+Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=711629
+Author: dod
+--- a/lib/JavaScript/Packer.pm
++++ b/lib/JavaScript/Packer.pm
+@@ -413,7 +413,7 @@
+         my %shrunk_vars = map { $_ => 1 } ( ${$javascript} =~ /$SHRINK_VARS->{SHRUNK}/g );
+ 
+         my $cnt = 0;
+-        foreach my $shrunk_var ( keys( %shrunk_vars ) ) {
++        foreach my $shrunk_var ( sort keys( %shrunk_vars ) ) {
+             my $short_id;
+             do {
+                 $short_id = $self->_encode52( $cnt++ );
+@@ -438,7 +438,7 @@
+             $words->{$_}->{count}++;
+         }
+ 
+-        WORD: foreach my $word ( sort { $words->{$b}->{count} <=> $words->{$a}->{count} } keys( %{$words} ) ) {
++        WORD: foreach my $word ( sort { $words->{$b}->{count} <=> $words->{$a}->{count} } sort keys( %{$words} ) ) {
+ 
+             if ( exists( $words->{$word}->{encoded} ) and $words->{$word}->{encoded} eq $word ) {
+                 next WORD;
+@@ -473,7 +473,7 @@
+ 
+         my ( @pk, @pattern ) = ( (), () );
+ 
+-        foreach ( sort { $words->{$a}->{index} <=> $words->{$b}->{index} } keys( %{$words} ) ) {
++        foreach ( sort { $words->{$a}->{index} <=> $words->{$b}->{index} } sort keys( %{$words} ) ) {
+             $packed_length -= ( $words->{$_}->{count} * $words->{$_}->{minus} );
+ 
+             if ( $words->{$_}->{encoded} ne $_ ) {
+@@ -645,7 +645,7 @@
+         if ( $do_shrink ) {
+ 
+             my $cnt = 0;
+-            foreach my $block_var ( keys( %block_vars ) ) {
++            foreach my $block_var ( sort keys( %block_vars ) ) {
+                 if ( length( $block_var ) ) {
+                     while ( $block =~ /$SHRINK_VARS->{PREFIX}\Q$cnt\E\b/ ) {
+                         $cnt++;
+--- a/t/scripts/s2-expected.js
++++ b/t/scripts/s2-expected.js
+@@ -1,2 +1,2 @@
+-function(b){var a='blah blubb';var d=3;alert(a);var f=1;//@a
+-var e=b;/*@abcd var f=1;@*/abcd var c=$H()};/*@abcd var x=1;@*/
+\ No newline at end of file
++function(c){var a='blah blubb';var e=3;alert(a);var d=1;//@a
++var b=c;/*@abcd var d=1;@*/abcd var f=$H()};/*@abcd var x=1;@*/
+\ No newline at end of file
+--- a/t/scripts/s3-expected.js
++++ b/t/scripts/s3-expected.js
+@@ -1 +1 @@
+-eval(function(p,a,c,k,e,r){e=String;if('0'.replace(0,e)==0){while(c--)r[e(c)]=k[c];k=[function(e){return r[e]||e}];e=function(){return'[024-9]'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('2(b){0 a=\'7 9\';0 d=3;8(a);0 6=1;//@a\n0 e=b;/*@4 0 6=1;@*/4 0 c=$5()};',[],10,'var||function||abcd|H|f|blah|alert|blubb'.split('|'),0,{}))
+\ No newline at end of file
++eval(function(p,a,c,k,e,r){e=String;if('0'.replace(0,e)==0){while(c--)r[e(c)]=k[c];k=[function(e){return r[e]||e}];e=function(){return'[024-9]'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('5(c){0 a=\'2 9\';0 e=3;8(a);0 d=1;//@a\n0 b=c;/*@4 0 d=1;@*/4 0 6=$7()};',[],10,'var||blah||abcd|function|f|H|alert|blubb'.split('|'),0,{}))
+\ No newline at end of file
+--- a/t/scripts/s4-expected.js
++++ b/t/scripts/s4-expected.js
+@@ -1,2 +1,2 @@
+-function(b){var a='blah blubb';var d=3;alert(a);var f=1;//@a
+-var e=b;/*@abcd var f=1;@*/abcd var c=$H()};/*@abcd var x=1;@*/
+\ No newline at end of file
++function(c){var a='blah blubb';var e=3;alert(a);var d=1;//@a
++var b=c;/*@abcd var d=1;@*/abcd var f=$H()};/*@abcd var x=1;@*/
+\ No newline at end of file
+--- a/t/scripts/s5-expected.js
++++ b/t/scripts/s5-expected.js
+@@ -1 +1 @@
+-eval(function(p,a,c,k,e,r){e=function(c){return(c<62?'':e(parseInt(c/62)))+((c=c%62)>35?String.fromCharCode(c+29):c.toString(36))};if('0'.replace(0,e)==0){while(c--)r[e(c)]=k[c];k=[function(e){return r[e]||e}];e=function(){return'([2-9h-zB-Z]|1[0-9a-zA-Z])'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('5 I=7 3(){5 c=7 Y();5 d=3(g){8(!g.2(\'F\'))n;7 B.u(\'/9\'+g.2(\'F\')+\'x.w?\'+6.h(6.l()*m)+\'=\'+6.h(6.l()*m),{v:\'2\',y:3(a){5 f=7 K(\'R\').o(a.t. [...]
+\ No newline at end of file
++eval(function(p,a,c,k,e,r){e=function(c){return(c<62?'':e(parseInt(c/62)))+((c=c%62)>35?String.fromCharCode(c+29):c.toString(36))};if('0'.replace(0,e)==0){while(c--)r[e(c)]=k[c];k=[function(e){return r[e]||e}];e=function(){return'([2-9h-zB-Z]|1[0-9a-zA-Z])'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('5 L=7 3(){5 g=7 W();5 f=3(e){9(!e.4(\'N\'))l;7 s.t(\'/h\'+e.4(\'N\')+\'w.v?\'+6.m(6.k()*8)+\'=\'+6.m(6.k()*8),{y:\'4\',z:3(d){5 c=7 G(\'I\').o(d.C. [...]
+\ No newline at end of file
+--- a/t/scripts/s10-expected.js
++++ b/t/scripts/s10-expected.js
+@@ -1 +1 @@
+-function initScript(){var a=parseXML("config.xml").getElementsByTagName("config");var b=parseXML('konfig.xml').getElementsByTagName('konfig');var c='conf.xml';var e='conf';var d=parseXML(c).getElementsByTagName(e)}
+\ No newline at end of file
++function initScript(){var c=parseXML("config.xml").getElementsByTagName("config");var e=parseXML('konfig.xml').getElementsByTagName('konfig');var b='conf.xml';var a='conf';var d=parseXML(b).getElementsByTagName(a)}
+\ No newline at end of file
+--- a/t/scripts/s8-expected.js
++++ b/t/scripts/s8-expected.js
+@@ -1 +1 @@
+-function(b){var d=x;var c=y;var a=(function(){return[].concat(arguments)[0][0]!==1})(1,do_somthing(do_something_else(d,c),d));if(a)arrayProto.concat=concat}
+\ No newline at end of file
++function(d){var b=x;var c=y;var a=(function(){return[].concat(arguments)[0][0]!==1})(1,do_somthing(do_something_else(b,c),b));if(a)arrayProto.concat=concat}
+\ No newline at end of file
+--- a/t/02-io.t
++++ b/t/02-io.t
+@@ -25,7 +25,7 @@
+     fileTest( 's7',  'clean',     'compression level "clean" function as argument' );
+     fileTest( 's8',  'shrink',    'compression level "shrink" function as argument' );
+     fileTest( 's9',  'shrink',    'compression level "shrink" with _no_shrink_ argument' );
+-    fileTest( 's10', 'shrink',    'compression level "shrink" with qouted args' );
++    fileTest( 's10', 'shrink',    'compression level "shrink" with quoted args' );
+ 
+     my $packer = JavaScript::Packer->init();
+ 
+@@ -52,7 +52,7 @@
+     is(
+         $var,
+         '/* BSD */'
+-            . "\neval(function(p,a,c,k,e,r){e=String;if('0'.replace(0,e)==0){while(c--)r[e(c)]=k[c];k=[function(e){return r[e]||e}];e=function(){return'[01]'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\\\b'+e(c)+'\\\\b','g'),k[c]);return p}('0 1=2;',[],2,'var|x'.split('|'),0,{}))",
++            . "\neval(function(p,a,c,k,e,r){e=String;if('0'.replace(0,e)==0){while(c--)r[e(c)]=k[c];k=[function(e){return r[e]||e}];e=function(){return'[01]'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\\\b'+e(c)+'\\\\b','g'),k[c]);return p}('1 0=2;',[],2,'x|var'.split('|'),0,{}))",
+         'copyright option compression level "obfuscate"'
+     );
+ 
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..686098f
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1 @@
+fix-random-var-name-issue

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libjavascript-packer-perl.git



More information about the Pkg-perl-cvs-commits mailing list