php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46060 Phar::addEmptyDir() breaks
Submitted: 2008-09-12 03:33 UTC Modified: 2008-09-13 20:57 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: xl269 at cam dot ac dot uk Assigned: cellog (profile)
Status: Closed Package: PHAR related
PHP Version: 5.3.0alpha2 OS: Debian GNU/Linux lenny
Private report: No CVE-ID: None
 [2008-09-12 03:33 UTC] xl269 at cam dot ac dot uk
Description:
------------
PharData::addEmptyDir() on a tar archive adds empty files instead of directories.




Reproduce code:
---------------
$zip = new PharData('test.tar');
$zip = $zip->convertToData(Phar::TAR, Phar::NONE); // compression scheme does not affect the result.
// Phar::ZIP is not buggy, but you need to add a file to the empty directory to see this.
$zip->startBuffering();
$zip->addEmptyDir('test/');
// $zip->addFile('file', 'test/file'); // see (*)
$zip->stopBuffering();


Expected result:
----------------
test.tar.bz2 should contain 1 empty directory "test"


Actual result:
--------------
test.tar.bz2 contains 1 empty *file* "test"

(*) doing this will create the directory "test" automatically, so that the tar archive now contains both a file and a directory called "test", and becomes unextractable.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-09-12 03:49 UTC] xl269 at cam dot ac dot uk
whoops, the "* result" sections should read "test.tar" not "test.tar.bz2" (if it isn't obvious). i was playing around with the bug whilst editing this report, and overlooked updating that part.
 [2008-09-12 16:43 UTC] xl269 at cam dot ac dot uk
the following will create an empty directory "test"
$zip->addFromString("test/", "");
 [2008-09-13 20:57 UTC] cellog@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

fixed in 5.3, HEAD and pecl, thanks for the report
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 12 20:01:27 2024 UTC