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: 2016-06-28 16:06 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: namatyage at gmail dot com Assigned:
Status: Verified Package: zip (PECL)
PHP Version: 7.0Git-2016-06-10 (Git) OS: OS X
Private report: No CVE-ID:
Have you experienced this issue?
Rate the importance of this bug to you:

 [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)

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

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).
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Tue Aug 29 15:01:52 2017 UTC