Bug #74619 [Com]: ZipArchive::ExtractTo cuts off file names

From: Date: Wed, 05 Apr 2023 08:50:28 +0000
Subject: Bug #74619 [Com]: ZipArchive::ExtractTo cuts off file names
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-244110@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74619&edit=1

 ID:                 74619
 Comment by:         ft1r1l at inf dot elte dot hu
 Reported by:        megaone at yandex dot ru
 Summary:            ZipArchive::ExtractTo cuts off file names
 Status:             Open
 Type:               Bug
 Package:            Zip Related
 Operating System:   Ubuntu, Debian
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

I cannot reproduce the codepage-independency of this bug. Using Debian Bullseye (PHP 7.4.33):

$ unzip -l zip.zip 
Archive:  zip.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  2023-04-05 10:25   áéíuó.txt
        0  2023-04-05 10:34   тест тест.txt
---------                     -------
        0                     2 files
$ cat zip.php 
<?php
$zip = new ZipArchive;
$zip->open('zip.zip');
$zip->extractTo('output/');


An ASCII locale is indeed broken:

$ LANG=C php zip.php
$ ls output/
 uó.txt  ' тест.txt'


However, a UTF-8 locale works as expected:

$ LANG=en_US.UTF-8 php zip.php
$ ls output/
 áéíuó.txt  'тест тест.txt'


Previous Comments:
------------------------------------------------------------------------
[2018-08-05 04:14:44] carusogabriel@php.net

Related To: Bug #69477

------------------------------------------------------------------------
[2017-12-14 10:16:22] 937787082 at qq dot com

I have the same problem.I can use "unzip -O cp936" get the filename.The filenam is wrong
when I use ZipArchive to get the file.
PHP 7.0.23 with Windows

------------------------------------------------------------------------
[2017-05-25 15:34:00] megaone at yandex dot ru

I've found that basename() does exactly the same, so it's seem to be related.

------------------------------------------------------------------------
[2017-05-21 04:37:39] megaone at yandex dot ru

Description:
------------
ExtractTo cuts off non latin file names, no matter of codepage, til first space, so
'имя файла.txt' becomes ' файла.txt'.
Filenames with no spaces gets cut off at all to extension only - '.txt'. getNameIndex
returns full file names.


Also ZipArchive relies on default_charset. When default_charset is different from archive charset,
files will be unpacked with broken names.


Problem appears on Ubuntu 12.04 with PHP 7.1.4 and with Debian 9 with PHP 7.0.16. First problem does
not appear on Windows.







------------------------------------------------------------------------



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


Thread (1 message)

  • ft1r1l at inf dot elte dot hu
  • Unknown Message
    • ft1r1l at inf dot elte dot hu
« previous php.bugs (#244110) next »