Skip Menu |

This queue is for tickets about the CGI-Cookie-Splitter CPAN distribution.

Report information
The Basics
Id: 81612
Status: resolved
Priority: 0/
Queue: CGI-Cookie-Splitter

People
Owner: ether [...] cpan.org
Requestors: ANDK [...] cpan.org
Cc: gregoa [...] cpan.org
AdminCc:

Bug Information
Severity: Important
Broken in: 0.02
Fixed in: 0.03



Subject: Test failures due to hash randomisation in perl 5.17.6
Since bleadperl v5.17.5-518-g7dc8663 your tests are failing frequently. That commit introduced hash key randomization and it seems at least the test t/basic.t is hit by that. Find a sample fail report at: http://www.cpantesters.org/cpan/report/aefec926-31d9-11e2-bd2d-f4c4a290f8f5 You can read more about the change at http://perl5.git.perl.org/perl.git/commit/7dc8663964c66a698d31bbdc8e8abed69bddeec3 or at http://www.perlmonks.org/?node_id=1005122 You may have to run the test several times until the randomization causes a fail. HTH&&Thanks&&Regards,
ETHER, GREGOA, All: attached is a patch to fix the problem. Apply it with -p1. It was written to fix a test failure with the package on Mageia Linux 4/Cauldron. I hereby disclaim any ownership of it. Some parts of the patch may not be necessary, but I prefered to include them, in order to be on the safe side. Regards, -- Shlomi Fish
Subject: CGI-Cookie-Splitter-0.02-params.patch
--- CGI-Cookie-Splitter-0.02/lib/CGI/Cookie/Splitter.pm.PARAMS_FIX_TESTS 2007-01-29 20:40:08.000000000 +0200 +++ CGI-Cookie-Splitter-0.02/lib/CGI/Cookie/Splitter.pm 2014-01-20 22:36:00.580499831 +0200 @@ -34,9 +34,11 @@ my ( $self, $cookie ) = @_; return $cookie unless $self->should_split( $cookie ); return $self->do_split_cookie( - $self->new_cookie( $cookie, - name => $self->mangle_name( $cookie->name, 0 ), - value => CORE::join("&",map { escape($_) } $cookie->value) # simplifies the string splitting + scalar( + $self->new_cookie( $cookie, + name => scalar($self->mangle_name( scalar($cookie->name), 0 )), + value => CORE::join("&",map { escape($_) } $cookie->value) # simplifies the string splitting + ) ) ); } @@ -44,7 +46,7 @@ sub do_split_cookie { my ( $self, $head ) = @_; - my $tail = $self->new_cookie( $head, value => '', name => $self->mangle_name_next( $head->name ) ); + my $tail = $self->new_cookie( $head, value => '', name => scalar($self->mangle_name_next(scalar( $head->name ))) ); my $max_value_size = $self->size - ( $self->cookie_size( $head ) - length( escape($head->value) ) ); $max_value_size -= 30; # account for overhead the cookie serializer might add @@ -101,12 +103,14 @@ sub new_cookie { my ( $self, $cookie, %params ) = @_; + my %out_params; for (qw/name secure path domain expires value/) { - next if exists $params{$_}; - $params{"-$_"} = $cookie->$_; + $out_params{"-$_"} = (exists($params{$_}) + ? $params{$_} : $cookie->$_ + ); } - blessed($cookie)->new( %params ); + blessed($cookie)->new( %out_params ); } sub should_split { @@ -129,7 +133,7 @@ } } - foreach my $name ( keys %split ) { + foreach my $name ( sort { $a cmp $b } keys %split ) { my $split_cookie = $split{$name}; croak "The cookie $name is missing some chunks" if grep { !defined } @$split_cookie; push @ret, $self->join_cookie( $name => @$split_cookie ); @@ -140,7 +144,7 @@ sub join_cookie { my ( $self, $name, @cookies ) = @_; - $self->new_cookie( $cookies[0], name => $name, value => $self->join_value( map { $_->value } @cookies ) ); + $self->new_cookie( $cookies[0], name => $name, value => scalar( $self->join_value( map { $_->value } @cookies )) ); } sub join_value { @@ -151,12 +155,12 @@ sub mangle_name_next { my ( $self, $mangled ) = @_; my ( $name, $index ) = $self->demangle_name( $mangled ); - $self->mangle_name( $name, $index+1 ); # can't trust magic incr because it might overflow and fudge 'chunk' + $self->mangle_name( $name, 1 + ((defined($index) ? $index : 0)) ); # can't trust magic incr because it might overflow and fudge 'chunk' } sub mangle_name { my ( $self, $name, $index ) = @_; - return sprintf '_bigcookie_%s_chunk%d', $name, $index; + return sprintf '_bigcookie_%s_chunk%d', +(defined($name) ? $name : ''), $index; } sub demangle_name { --- CGI-Cookie-Splitter-0.02/t/basic.t.PARAMS_FIX_TESTS 2007-01-29 20:40:23.000000000 +0200 +++ CGI-Cookie-Splitter-0.02/t/basic.t 2014-01-20 22:39:29.228265504 +0200 @@ -60,7 +60,7 @@ num_cookies => 3, cookie => { -name => "f", - secure => 1, + -secure => 1, -value => { foo => ("a" x 1000), bar => ("b" x 1000) }, }, }, @@ -120,7 +120,7 @@ while( @all_joined and my($joined, $orig) = ( shift @all_joined, shift @all_cookies ) ) { foreach my $field ( qw/name value domain path secure/ ) { - is_deeply( eval { [ $joined->$field ] }, eval { [ $orig->$field ] }, "'$field' is the same" ); + is_deeply( [ eval { $joined->$field } ], [ eval { $orig->$field } ], "'$field' is the same" ); } } }
Subject: Re: [rt.cpan.org #81612] Test failures due to hash randomisation in perl 5.17.6
Date: Mon, 20 Jan 2014 23:06:18 +0100
To: Shlomi Fish via RT <bug-CGI-Cookie-Splitter [...] rt.cpan.org>
From: gregor herrmann <gregoa [...] debian.org>
On Mon, 20 Jan 2014 15:46:04 -0500, Shlomi Fish via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=81612 > > > attached is a patch to fix the problem. Apply it with -p1. It was > written to fix a test failure with the package on Mageia Linux > 4/Cauldron. I hereby disclaim any ownership of it. Some parts of > the patch may not be necessary, but I prefered to include them, in > order to be on the safe side.
Cool, thanks alot! Uploading the package with the patch to Debian/unstable right now. Cheers, gregor -- .''`. Homepage: http://info.comodo.priv.at/ - OpenPGP key 0xBB3A68018649AA06 : :' : Debian GNU/Linux user, admin, and developer - http://www.debian.org/ `. `' Member of VIBE!AT & SPI, fellow of the Free Software Foundation Europe `- NP: Beatles
Download signature.asc
application/pgp-signature 819b

Message body not shown because it is not plain text.

thanks, 0.03 released!