Subject: | Archive::Zip does not correctly add files named "0" (zero) |
Hello,
We've just discovered that Archive::Zip can't handle files names "0"
(zero). Yes I know what you think right now but don't ask why or how,
I'm not the one who chose to use such a name :-/
Here is a small script to demonstrate the problem:
use strict;
use Archive::Zip;
my $path = shift || die "need a file or directory name\n";
my $archive = Archive::Zip->new;
$archive->addTree($path, $path);
$archive->writeToFileNamed("$path.zip");
and a directory with two files (named "0" and "1"):
$ ls -lF folder/
-rw-r--r-- 1 saper saper 35587 jun 6 11:45 0
-rwxr-xr-x 1 saper saper 2530 jun 6 11:46 1*
Now if I execute the script
$ perl archive-zip.pl folder
the created archive looks like this:
$ unzip -l folder.zip
Archive: folder.zip
Length Date Time Name
-------- ---- ---- ----
0 06-06-07 15:02 folder/
35587 06-06-07 11:45 folder/
2530 06-06-07 11:46 folder/1
-------- -------
38117 3 files
The entry for "0" is here, except for its name.
After digging through Archive::Zip code, I isolated the bug in the
function _asZipDirName(). Attached is the patch to fix it.
Thanks in advance
--
Close the world, txEn eht nepO.
Subject: | Archive-Zip-1.20-handle-zero.diff |
diff -ru Archive-Zip-1.20-orig/lib/Archive/Zip.pm Archive-Zip-1.20/lib/Archive/Zip.pm
--- Archive-Zip-1.20-orig/lib/Archive/Zip.pm 2007-06-05 03:48:29.000000000 +0200
+++ Archive-Zip-1.20/lib/Archive/Zip.pm 2007-06-06 15:40:59.842075006 +0200
@@ -514,7 +514,7 @@
$$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, $file || '' );
+ push ( @dirs, defined($file) ? $file : '' );
#return wantarray ? @dirs : join ( '/', @dirs );
return join ( '/', @dirs );
}