|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2016-05-24 10:29 UTC] cmb@php.net
[2016-05-24 11:49 UTC] speller at yandex dot ru
-Summary: ZipArchive converts filenames to unrecoverableform
+Summary: ZipArchive converts filenames to unrecoverable form
[2016-05-24 11:49 UTC] speller at yandex dot ru
[2016-05-25 18:52 UTC] ab@php.net
-Status: Open
+Status: Analyzed
[2016-05-25 18:52 UTC] ab@php.net
[2016-05-25 18:52 UTC] ab@php.net
-Assigned To:
+Assigned To: ab
[2016-05-30 12:06 UTC] ab@php.net
-Type: Bug
+Type: Documentation Problem
[2016-05-30 12:06 UTC] ab@php.net
[2016-05-30 21:15 UTC] ab@php.net
-Assigned To: ab
+Assigned To:
[2016-07-19 09:59 UTC] ab@php.net
-Status: Analyzed
+Status: Closed
-Assigned To:
+Assigned To: ab
[2016-07-19 09:59 UTC] ab@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 17:00:01 2025 UTC |
Description: ------------ I have a test zip archive with only one dir named (АБВГД) created under Windows with Russian locale. If you will look to the zip file in HEX mode you will see the dir name "80 81 82 83 84 2F" (АБВГД/), five 1-byte chars + slash. Under PHP 5.4 the ZipArchive::getNameIndex function onthis archive returned the name as is - in cp866 encoding. So I was able to convert it to correct text. After upgrading to PHP 5.6 this function returns names transcoded to something unrecoverable. The result of the ZipArchive::getNameIndex transcoded by PHP internally to five *2-bytes* chars + slash! I tried to set default_encoding ini setting, but without success. So I can not work properly with such archives at all. Run test script under precompiled PHP 5.4 from the php.net and the same PHP 5.6 and you will see different results: Test script: --------------- <? echo setlocale(LC_ALL, 'Russian_Russia.20866'), "\n"; ini_set('default_charset', 'cp866'); $zip = new \ZipArchive(); $res = $zip->open('test.zip'); if ($res !== true) { echo 'Error opening: ' . $res; die(); } for ($i = 0; $i < $zip->numFiles; $i++) { $stat = $zip->statIndex($i); $fileNameInArc = $zip->getNameIndex($i); echo $fileNameInArc, "\n"; echo iconv('cp866', 'utf-8', $fileNameInArc), "\n"; } Expected result: ---------------- php.5.4.32\php test.php Russian_Russia.20866 АБВГД/ ╨Р╨С╨Т╨У╨Ф/ Actual result: -------------- php.5.6.21\php test.php Russian_Russia.20866 ├З├╝├й├в├д/ тФЬ╨ЧтФЬтХЭтФЬ╨╣тФЬ╨▓тФЬ╨┤/