php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57303 cannot open Info-ZIP zip archives
Submitted: 2006-10-18 12:28 UTC Modified: 2006-10-20 13:53 UTC
From: jumpmanjay at juno dot com Assigned: pajoye (profile)
Status: Closed Package: zip (PECL)
PHP Version: 5.1.6 OS: Windows 2003 Server Std Ed
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jumpmanjay at juno dot com
New email:
PHP Version: OS:

 

 [2006-10-18 12:28 UTC] jumpmanjay at juno dot com
Description:
------------
Zip  enabled  
Extension Version  $Id: php_zip.c,v 1.70 2006/08/14 15:54:34 pajoye Exp $  
Zip version  @PACKAGE_VERSION@  
Libzip version  0.7.1  

basically, we have a software provider that zips up logs automatically using Info-ZIP. the extensions used on php4 used to work with these logs, but it appears the new PECL ones dont. if i take the archive created, unzip it and re-zip it using either windoes compressed files, winzip, or winrar, the code below works as it should.

re-zipping each file is not a real workaround...

<a href="http://www.jasonyokoyama.com/misc/test.zip">here is a link to an example zip archive (ive even included the zip executable in the archive used to create this archive.</a>

thanks!

Reproduce code:
---------------
$filename=$dir.$file.".zip";

$zip = new ZipArchive;
$res = $zip->open(realpath($filename));
if ($res === TRUE) 
{
   echo 'ok';
   $zip->extractTo('/www/ticketuploads/'.$username.'/'.$username);
   $zip->close();
}
else
{
   echo 'failed, code:' . $res;
}

Expected result:
----------------
expect to see zip contents in folder

Actual result:
--------------
it creates the folder, but with no contents

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-10-18 13:23 UTC] pierre dot php at gmail dot com
For some reasons, entries in your archive looks like:

"tt/logfiles//ipconfig.txt"

This is not a valid path neither a valid entry name. I can try to work around this but I do not think it is actually a good idea.

I will test further later.
 [2006-10-18 13:27 UTC] pierre dot php at gmail dot com
For the record, you can list the entries using this little snippet (you do not need absolute path anymore):

$zip = new ZipArchive;
$res = $zip->open("bug9082.zip");
for ($i=0; $i<$zip->numFiles;$i++) {
  echo "index: $i\n";
  print_r($zip->statIndex($i));
}
 [2006-10-18 13:44 UTC] jumpmanjay at juno dot com
i would get error code 11 (dont know what that means) when i would try to open the zip file using the relative path.
 [2006-10-18 13:53 UTC] pierre dot php at gmail dot com
Please use a more recent version, can you fetch a recent dll from pecl4win and try again? The relative path problem has been solved.

Please note that I can reproduce the problem with your zip archive, but as I said, I'm not sure if it is a good thing to create a work around for badly named entries.
 [2006-10-18 14:06 UTC] jumpmanjay at juno dot com
im using the 5.1.6 PECL build...

...can there be a non-default flag to utilize non-standard entries? other zip programs can read them no problem...and as stated, the old php4 zip dll read them without a problem...

thanks!
 [2006-10-18 14:10 UTC] pierre dot php at gmail dot com
The problem is not ext/zip. Zip can read it smoothly. But mkdir does not work with paths like "./tmp/foo//bar/logs":

mkdir("./tmp/foo//bar/logs",0777, true);

Warning: mkdir(): No such file or directory in..
 [2006-10-18 14:21 UTC] jumpmanjay at juno dot com
cant just do 

mkdir(str_replace('//','/',$path),0777, true);

?
:)
 [2006-10-19 07:28 UTC] pierre dot php at gmail dot com
Please try using the latest php snapshot. You can fetch 5.2 windows binary snapshots here:

http://snaps.php.net/

Zip is bundled. You do not need to get the zip dll, however the problem has been fixed in php's mkdir.
 [2006-10-19 12:22 UTC] jumpmanjay at juno dot com
i am using snapshot 200610191430 and am still getting the same problem...
 [2006-10-19 12:40 UTC] pierre dot php at gmail dot com
Be sure to load the correct extension. The one in the 5.2 snapshot. I did test under windows and the extractTo works like a charm.
 [2006-10-20 07:36 UTC] pierre dot php at gmail dot com
Edin, who is our windows builder and master, confirmed that it works nicely with 5.2.0 latest snaps (or RC6).
 [2006-10-20 09:51 UTC] pierre dot php at gmail dot com
For the record, I will add a work around in the zip extension itself. It will be available in the next PECL release and via pecl4win for php 5.1.

move to "assigned"
 [2006-10-20 10:28 UTC] pierre dot php at gmail dot com
The next 5_1 DLL in pecl4win.php.net should contain the fix. Please try it and tell me if it works as expected.
 [2006-10-20 12:02 UTC] jumpmanjay at juno dot com
the new snapshot worked...there was an error in my referencing it with extractto. (i wanted to just extract one file, and needed to reference that one file with the "//" instead of "/").

thanks!
 [2006-10-20 13:53 UTC] pierre dot php at gmail dot com
Thank you for this report :)

> closed, problem solved.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Dec 02 23:03:35 2021 UTC