Subject: | IO::Uncompress::Unzip sets eof when zip file has multiple folders |
Date: | Thu, 7 Nov 2013 15:57:22 +0000 |
To: | "bug-IO-Compress [...] rt.cpan.org" <bug-IO-Compress [...] rt.cpan.org> |
From: | "Hardies, Jason" <Jason.Hardies [...] wolterskluwer.com> |
I've encountered a bug that was introduced sometime between IO::Compress versions 2.030 and 2.061. When reading a zip file whose content is inside 2 or more layers of folders, IO::Uncompress::Unzip immediately sets the eof flag. I've attached an example file that causes this issue. The code below will reproduce the issue if the content of the file is in $buffer.
my $z = new IO::Uncompress::Unzip \$buffer;
print "EOF:".$z->eof()."\n";
With version 2.030, when reading the zip file, the first item read was a folder item where $z->getHeaderInfo()->{Name} would be set to something like "Folder\Sub1\". I think IO::Uncompress::Unzip is not seeing the status it wants when it checks the first item of the zip file. It reads the zip file properly if I comment out the contents of the if ($status) block in sub _create in IO::Uncompress::Base.
if ($status) {
# Need to try uncompressing to catch the case
# where the compressed file uncompresses to an
# empty string - so eof is set immediately.
my $out_buffer = '';
$status = $obj->read(\$out_buffer);
if ($status < 0) {
*$obj->{ReadStatus} = [ $status, $obj->error(), $obj->errorNo() ];
}
$obj->ungetc($out_buffer)
if length $out_buffer;
}
else {
Thanks,
Jason Hardies
Message body not shown because it is not plain text.