Bug #79736 [ReO->Nab]: ZipArchive accepts backslashes for file names
| From: | cmb@php.net | Date: | Tue, 07 Jul 2020 08:18:41 +0000 |
| Subject: | Bug #79736 [ReO->Nab]: ZipArchive accepts backslashes for file names | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-227841@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79736&edit=1
ID: 79736
Updated by: cmb@php.net
Reported by: edultra at gmail dot com
-Summary: ZipArchive
+Summary: ZipArchive accepts backslashes for file names
-Status: Re-Opened
+Status: Not a bug
Type: Bug
Package: Zip Related
Operating System: Windows and Linux
PHP Version: 7.2.31
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
ZipArchive is very liberal in what it accepts as filename (i.e.
$localname), and as such accepts backslashes. The documentation
of ZipArchive::addFile()[1] (and other relevant methods) states:
| For maximum portability, it is recommended to always use forward
| slashes (/) as directory separator in ZIP filenames.
[1] <https://www.php.net/manual/en/ziparchive.addfile.php>
Previous Comments:
------------------------------------------------------------------------
[2020-06-25 18:52:07] requinix@php.net
When you use ziparchive to zip a folder with
subfolders and files on a windows server it creates the file, however
decompression on a Linux server the files are all wrong,
from what I was able to discover is due to the position of the bar that it does
for windows example:
the folder on windows contains the following structure / files:
index.html
images
image1.jpg
image2.jpg
image3.jpg
styles
style.css
content
home.html
chapter.html
footer.html
From what I saw he saves the way to decompress
index.html
images \ image1.jpg
images \ image2.jpg
images \ image3.jpg
styles \ style.css
content \ home.html
content \ chapter.html
content \ footer.html
See that the position in the windows of the bar is \ however in this position the
php interprets that it is to disregard the next character getting
so the paths in linux:
index.html
images \ mage1.jpg
images \ mage2.jpg
images \ mage3.jpg
styles \ tyle.css
content \ ome.html
content \ apitulo.html
content \ ooter.html
The root files are successfully extracted but the others generate
all wrong files.
Expected result:
----------------
That the files are extracted correctly both those generated in the
windows and extracted in linux and vice versa.
Actual result:
--------------
The files are extracted all with problem.
------------------------------------------------------------------------
[2020-06-25 18:49:05] peehaa@php.net
Non English.
If you think this is a valid bug report feel free to submit it again in English.
------------------------------------------------------------------------
[2020-06-25 18:45:33] edultra at gmail dot com
Description:
------------
Quando você utiliza o ziparchive para criar um zip de uma pasta com subpastas e arquivos em um
servidor windows ele cria o arquivo, porém na descompressão em um servidor Linux os arquivos
ficam todos errados, pelo que consegui descobrir é devido a posição da barra que ele faz
para o windows exemplo:
a pasta no windows contém a seguinte estrutura/arquivos:
index.html
images
image1.jpg
image2.jpg
image3.jpg
styles
style.css
content
home.html
capitulo.html
footer.html
Pelo que vi ele salva o caminho para despois descomprimir
index.html
images\image1.jpg
images\image2.jpg
images\image3.jpg
styles\style.css
content\home.html
content\capitulo.html
content\footer.html
Vejam que a posição no windows da barra é \ porém nesta posição o php interpreta
que é para desconsiderar o próximo caracter ficando assim os caminhos no linux:
index.html
images\mage1.jpg
images\mage2.jpg
images\mage3.jpg
styles\tyle.css
content\ome.html
content\apitulo.html
content\ooter.html
Os arquivos na raiz são extrai dos com sucesso mas os outros geram arquivos todos errados.
Expected result:
----------------
Que os arquivos sejam extrai dos corretamente tanto os gerados no windows e extraidos no linux e
vice-versa.
Actual result:
--------------
Os arquivos são extraidos todos com problema.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79736&edit=1