Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

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

Report information
The Basics
Id:
76780
Status:
open
Priority:
Low/Low
Queue:

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

BugTracker
Severity:
(no value)
Broken in:
1.31_04
Fixed in:
(no value)



Subject: Cannot create member called "0" with addString
This issue concerns addString, where the member name is "0". This code will trigger the issue use strict; use warnings; # Create a Zip file use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); my $zip = Archive::Zip->new(); my $string_member = $zip->addString("abc" => 0); # Save the Zip file unless ( $zip->writeToFileNamed('someZip.zip') == AZ_OK ) { die 'write error\n'; } Here is the error I get with 1.31_04 $ perl -Mblib try.pl error: no member name given for Archive::Zip::StringMember=HASH(0x9140960) at /linux-shared/Archive-Zip-1.31_04/blib/lib/Archive/Zip/Member.pm line 1055. Archive::Zip::Member::_writeToFileHandle('Archive::Zip::StringMember=HASH(0x9140960)', 'IO::File=GLOB(0x9140e20)', 1, 0) called at /linux-shared/Archive-Zip-1.31_04/blib/lib/Archive/Zip/Archive.pm line 428 Archive::Zip::Archive::writeToFileHandle('Archive::Zip::Archive=HASH(0x8e41758)', 'IO::File=GLOB(0x9140e20)', 1) called at /linux-shared/Archive-Zip-1.31_04/blib/lib/Archive/Zip/Archive.pm line 396 Archive::Zip::Archive::writeToFileNamed('Archive::Zip::Archive=HASH(0x8e41758)', 'someZip.zip') called at try.pl line 10 write error\n at try.pl line 11. I'll post a patch shortly. Paul
Enclosed patch should sort the issue. Paul
Subject: 76780.patch
*** lib/Archive/Zip/Member.pm.orig 2012-04-19 08:27:41.000000000 +0100 --- lib/Archive/Zip/Member.pm 2012-04-23 22:46:52.000000000 +0100 *************** *** 229,235 **** sub fileName { my $self = shift; my $newName = shift; ! if ($newName) { $newName =~ s{[\\/]+}{/}g; # deal with dos/windoze problems $self->{'fileName'} = $newName; } --- 229,235 ---- sub fileName { my $self = shift; my $newName = shift; ! if (defined $newName) { $newName =~ s{[\\/]+}{/}g; # deal with dos/windoze problems $self->{'fileName'} = $newName; } *** t/07_filenames_of_0.t.orig 2012-04-19 08:32:39.000000000 +0100 --- t/07_filenames_of_0.t 2012-04-23 22:46:39.000000000 +0100 *************** *** 2,7 **** --- 2,8 ---- # 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 # # It tests that one can add files to the archive whose filenames are "0". *************** *** 11,21 **** $^W = 1; } ! use Test::More tests => 1; ! use Archive::Zip; ! use File::Path; use File::Spec; mkpath([ File::Spec->catdir('testdir', 'folder') ]); --- 12,28 ---- $^W = 1; } ! use Test::More tests => 3; use File::Path; use File::Spec; + use Archive::Zip; + BEGIN { + unshift @INC, "t/"; + require( File::Spec->catfile('t', 'common.pl') ) + or die "Can't load t/common.pl"; + } + + mkpath([ File::Spec->catdir('testdir', 'folder') ]); *************** *** 42,44 **** --- 49,73 ---- ); rmtree([ File::Spec->catdir('testdir', 'folder') ]); + + { + # Regression for #76780: Cannot create member called "0" with addString + + { + # Create member "0" with addString + my $archive = Archive::Zip->new; + my $string_member = $archive->addString(TESTSTRING => 0); + $archive->writeToFileNamed(OUTPUTZIP); + } + + { + # Read member "0" + my $archive = Archive::Zip->new; + is ($archive->read( OUTPUTZIP ), Archive::Zip::AZ_OK); + ok(scalar(grep { $_ eq "0" } $archive->memberNames()), + "Checking that a file called '0' was added properly by addString") ; + } + + unlink(OUTPUTZIP); + } +
Hello Paul, Thank you for the bug report as well as for the patch. It has been applied in the source tree: http://svn.ali.as/cpan/trunk/Archive-Zip/ Regards, Alan Haggai Alavi. -- The difference makes the difference


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

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