php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72374 ZipArchive::addGlob remove_path option strips first char of filename
Submitted: 2016-06-10 07:57 UTC Modified: 2019-10-02 13:37 UTC
Votes:2
Avg. Score:4.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:0 (0.0%)
From: namatyage at gmail dot com Assigned: cmb (profile)
Status: Closed Package: zip (PECL)
PHP Version: 7.0Git-2016-06-10 (Git) OS: OS X
Private report: No CVE-ID: None
 [2016-06-10 07:57 UTC] namatyage at gmail dot com
Description:
------------
After adding a file by addGlob using add_path and remove_path options, the first character of the filename is stripped in the archive.


Test script:
---------------
<?php
$file = 'foo-bar';
touch($file);

$zip = new ZipArchive();
$zip->open('test.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE);
$options = array('add_path' => 'prefix-', 'remove_path' => 'foo-');
$zip->addGlob($file, 0, $options);

for($i = 0; $i < $zip->numFiles; $i++) {
	$sb = $zip->statIndex($i);
	echo $sb['name'];
}

$zip->close();


Expected result:
----------------
prefix-bar

Actual result:
--------------
prefix-ar

Patches

ziparchive-remove-path-length-option.patch (last revision 2016-06-10 07:57 UTC by namatyage at gmail dot com)

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-06-28 16:06 UTC] cmb@php.net
-Status: Open +Status: Verified
 [2016-06-28 16:06 UTC] cmb@php.net
I can confirm the issue on Windows (tested PHP 5.4.19, 5.6.15 and
7.0.7).
 [2019-10-02 13:34 UTC] cmb@php.net
Automatic comment on behalf of namatyage@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=4d6f88e2152888e4e4e8ac40c2d4a68d28b6a208
Log: Fix #72374: remove_path strips first char of filename
 [2019-10-02 13:34 UTC] cmb@php.net
-Status: Verified +Status: Closed
 [2019-10-02 13:37 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 17:01:58 2024 UTC