Bug #51857 [Com]: deleteName() for directories returns True on non-success

2012-05-23 Thread maxspeed40k at gmail dot com
Edit report at https://bugs.php.net/bug.php?id=51857&edit=1

 ID: 51857
 Comment by: maxspeed40k at gmail dot com
 Reported by:nuabaranda at web dot de
 Summary:deleteName() for directories returns True on
 non-success
 Status: Feedback
 Type:   Bug
 Package:Zip Related
 Operating System:   Linux 2.6.27
 PHP Version:5.3.3-dev
 Assigned To:pajoye
 Block user comment: N
 Private report: N

 New Comment:

reproduce the problem
PHP Version: 5.4.3
OS: windows 7


Previous Comments:

[2010-09-14 15:19:48] paj...@php.net

Please try using this snapshot:

  http://snaps.php.net/php5.3-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/

I can't reproduce the problem, can you try again pls?


[2010-05-21 19:41:42] phi...@php.net

And for good measure:

open(FILEPATH_ZIPFILE, ZIPARCHIVE::CREATE) === TRUE) {

$zip->addFromString('foo.txt', 'foo');
$zip->addFromString('bar.txt', 'bar');
$zip->addEmptyDir('EmptyDirectory');
$zip->addEmptyDir('FullDirectory');
$zip->addFromString('FullDirectory/baz.txt', 'baz');
$zip->close();
}

/* Mess with the Zip file */
$zip = new ZipArchive;
if ($zip->open(FILEPATH_ZIPFILE) === TRUE) {

/* Fails to delete */
$r1 = $zip->deleteName('EmptyDirectory');

/* Successful delete (note the appended '/' */
$r2 = $zip->deleteName('EmptyDirectory/');

/* Fails to delete */
$r3 = $zip->deleteName('FullDirectory');

/* Fails to delete, although returns true */
$r4 = $zip->deleteName('FullDirectory/');

$zip->close();
}

/* Display the Zip file contents */
$zip = new ZipArchive;
if ($zip->open(FILEPATH_ZIPFILE) === TRUE) {

echo 'File count: ', $zip->numFiles, PHP_EOL;
echo 'Status: ', $zip->status, PHP_EOL;

for ($i = 0; $i < $zip->numFiles; $i++) {
$stat = $zip->statIndex($i);
echo 'Index: ', $i, ' ', $stat['name'], PHP_EOL;
}

$zip->close();
}

var_dump(
array('r1' => $r1, 'r2' => $r2, 'r3' => $r3, 'r4' => $r4)
);

Returns:

File count: 3
Status: 0
Index: 0 foo.txt
Index: 1 bar.txt
Index: 2 FullDirectory/baz.txt
array(4) {
  ["r1"]=>
  bool(false)
  ["r2"]=>
  bool(true)
  ["r3"]=>
  bool(false)
  ["r4"]=>
  bool(true)
}


[2010-05-19 09:43:27] nuabaranda at web dot de

Description:

When trying to delete a non-empty directory in a ZIP file with deleteName() the 
function will return True and not delete the directory if it is not empty. 
Expectation would be to return False if the directory can not be deleted.

Also the directory handling should be better documentated (usage of trailing 
slashes, examples).

Test script:
---
$zip = new ZipArchive;
if( $zip->open('archive.zip', ZipArchive::CREATE) ) {
  $zip->addEmptyDir('folder');
  $zip->addFile('folder/file.txt');
  if( ! $zip->deleteName('folder/') ) {
echo 'Should end up here if folder not deletable';
  }
}
$zip->close();

Expected result:

Should echo.

Actual result:
--
Will not echo.






-- 
Edit this bug report at https://bugs.php.net/bug.php?id=51857&edit=1


Bug #51929 [Com]: Extracted a zip file that contains a folder named with Chinese characters

2012-06-07 Thread maxspeed40k at gmail dot com
Edit report at https://bugs.php.net/bug.php?id=51929&edit=1

 ID: 51929
 Comment by: maxspeed40k at gmail dot com
 Reported by:kgo_yoi at hotmail dot com
 Summary:Extracted a zip file that contains a folder named
 with Chinese characters
 Status: Assigned
 Type:   Bug
 Package:Zip Related
 Operating System:   Windows XP Simplified Chinese
 PHP Version:5.2.13
 Assigned To:pajoye
 Block user comment: N
 Private report: N

 New Comment:

windows 7 (32bit)
php 5.4


Previous Comments:

[2011-08-24 05:36:52] chrodos at gmail dot com

I also confirm this bug in the Greek language. The problem is that it has 
severe implications in popular opensource applications like moodle. 

Please read related bug: http://tracker.moodle.org/browse/MDL-24928


[2011-05-30 08:51:41] mikhail dot v dot gavrilov at gmail dot com

I also confirm this problem.

Workaround: Helps converting to your DOS encoding.


[2011-02-18 14:05:12] paj...@php.net

At some point the library will support UTF-8 (as zip specs allow that). But it 
is 
not yet implemented.


[2011-02-18 14:04:29] paj...@php.net

the library does nothing but to take the names you give as inputs.

The problem is also visible when a zip archive contains entries namend using 
UTF-8 
or other random encoding. These names are used to the filesystem APIs, which 
expect string endonded using the active run time CP.


[2011-02-18 13:58:12] g dot faust at tarent dot de

Like Bug #53948 (ZIP archive UTF-8 filenames problem) the problem seems to be 
the zip-implementation which (seems to) expects CP437 as valid encoding for 
file-/foldernames.

using 

$newFileOrFoldername = iconv('UTF-8', 'CP437//IGNORE//TRANSLIT', 
$oldFileOrFoldername);

as a Workaround, you have to look that iconv() supports CP437.
After this Workaround it works* with Win7(64bit) and Ubuntu 10.4(64bit) but the 
Archivemanager under Ubuntu 10.4(32bit) still shows wrong characters.

*) With the converted Filename where characters not-matching CP437 will be 
transliterated or even ignored - so it may be not a Workaround for Chinese 
characters ...




The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

https://bugs.php.net/bug.php?id=51929


-- 
Edit this bug report at https://bugs.php.net/bug.php?id=51929&edit=1