Skip Menu |
 

This queue is for tickets about the Archive-Zip CPAN distribution.

Report information
The Basics
Id: 70607
Status: open
Priority: 0/
Queue: Archive-Zip

People
Owner: Nobody in particular
Requestors: pmqs [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.31_04
Fixed in: (no value)



Subject: Problem with directory named "0"
Download (untitled) / with headers
text/plain 1.5k
This is a variation on RT #27463, except the issue here is when a directory name is "0". The problem can be triggered using the zip.pl script in the examples directory $ mkdir fred fred/0 fred/1 $ perl examples/zip.pl z.zip fred/* Now check what is in the zip file - note the missing fred/0/ directory entry $ unzip -l z.zip Archive: z.zip Length Date Time Name --------- ---------- ----- ---- 0 2011-08-30 16:55 fred/ 0 2011-08-30 16:55 fred/1/ --------- ------- 0 2 files The patch below fixed the issue for me. *** lib/Archive/Zip.pm.orig 2011-08-30 16:59:49.000000000 +0100 --- lib/Archive/Zip.pm 2011-08-30 16:59:54.000000000 +0100 *************** *** 519,525 **** File::Spec->splitpath( File::Spec->canonpath($name), $forceDir ); $$volReturn = $volume if ( ref($volReturn) ); my @dirs = map { $_ =~ s{/}{_}g; $_ } File::Spec- Show quoted text
>splitdir($directories);
! if ( @dirs > 0 ) { pop (@dirs) unless $dirs[-1] } # remove empty component push ( @dirs, defined($file) ? $file : '' ); #return wantarray ? @dirs : join ( '/', @dirs ); --- 519,525 ---- File::Spec->splitpath( File::Spec->canonpath($name), $forceDir ); $$volReturn = $volume if ( ref($volReturn) ); my @dirs = map { $_ =~ s{/}{_}g; $_ } File::Spec- Show quoted text
>splitdir($directories);
! if ( @dirs > 0 ) { pop (@dirs) if $dirs[-1] eq '' } # remove empty component push ( @dirs, defined($file) ? $file : '' ); #return wantarray ? @dirs : join ( '/', @dirs ); cheers Paul
Download (untitled) / with headers
text/plain 113b
Updated patch for 1.31_04 with regression test enclosed. Assumes patch for RT# 76780 is already applied. Paul
Subject: 70607.patch
Download 70607.patch
text/x-diff 2.5k
*** lib/Archive/Zip.pm.orig 2012-04-23 22:56:10.000000000 +0100 --- lib/Archive/Zip.pm 2012-04-23 23:25:10.000000000 +0100 *************** *** 524,530 **** File::Spec->splitpath( File::Spec->canonpath($name), $forceDir ); $$volReturn = $volume if ( ref($volReturn) ); my @dirs = map { $_ =~ s{/}{_}g; $_ } File::Spec->splitdir($directories); ! if ( @dirs > 0 ) { pop (@dirs) unless $dirs[-1] } # remove empty component push ( @dirs, defined($file) ? $file : '' ); #return wantarray ? @dirs : join ( '/', @dirs ); --- 524,530 ---- File::Spec->splitpath( File::Spec->canonpath($name), $forceDir ); $$volReturn = $volume if ( ref($volReturn) ); my @dirs = map { $_ =~ s{/}{_}g; $_ } File::Spec->splitdir($directories); ! if ( @dirs > 0 ) { pop (@dirs) if $dirs[-1] eq '' } # remove empty component push ( @dirs, defined($file) ? $file : '' ); #return wantarray ? @dirs : join ( '/', @dirs ); *** t/07_filenames_of_0.t.orig 2012-04-23 22:56:19.000000000 +0100 --- t/07_filenames_of_0.t 2012-04-23 23:25:00.000000000 +0100 *************** *** 3,8 **** --- 3,9 ---- # This is a regression test for: # http://rt.cpan.org/Public/Bug/Display.html?id=27463 # http://rt.cpan.org/Public/Bug/Display.html?id=76780 + # http://rt.cpan.org/Public/Bug/Display.html?id=70607 # # It tests that one can add files to the archive whose filenames are "0". *************** *** 12,18 **** $^W = 1; } ! use Test::More tests => 3; use File::Path; use File::Spec; use Archive::Zip; --- 13,19 ---- $^W = 1; } ! use Test::More tests => 5; use File::Path; use File::Spec; use Archive::Zip; *************** *** 71,73 **** --- 72,101 ---- unlink(OUTPUTZIP); } + { + # Regression for #70607: Problem with directory named "0" + + my $name = File::Spec->catdir('testdir', 'zero') ; + my $name1 = File::Spec->catdir($name, '0') ; + mkpath([ $name1 ]); + + { + # Create member "0" with addTree + my $archive = Archive::Zip->new; + my $string_member = $archive->addTree($name, $name); + $archive->writeToFileNamed(OUTPUTZIP); + } + + { + # Read member "0" + my $archive = Archive::Zip->new; + is ($archive->read( OUTPUTZIP ), Archive::Zip::AZ_OK); + my @names = $archive->memberNames(); + ok(scalar(grep { $_ eq 'testdir/zero/0/' } $archive->memberNames()), + "Checking that a directory called '0' was added properly by addTree") ; + } + + rmtree([ $name ]); + unlink(OUTPUTZIP); + } +


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.