Req #80372 [Com]: Allow ZipArchive to open archive from string or at least data URL
Edit report at https://bugs.php.net/bug.php?id=80372&edit=1
ID: 80372
Comment by: michael dot vorisek at email dot cz
Reported by: michael dot vorisek at email dot cz
Summary: Allow ZipArchive to open archive from string or at
least data URL
Status: Open
Type: Feature/Change Request
Package: Zip Related
PHP Version: 7.4.12
Block user comment: N
Private report: N
New Comment:
Good news - it should be possible!
https://github.com/nih-at/libzip/issues/220
Previous Comments:
------------------------------------------------------------------------
[2020-11-17 15:01:27] michael dot vorisek at email dot cz
> Not even if you pass ZipArchive::OPEN_RDONLY as $flag to ::open()?
if the file is not stored on disk (come from upload/database/api and can not be written even to tmp
directory (as RO too)) then currently there is no way to read it with the zip extension
------------------------------------------------------------------------
[2020-11-17 12:36:24] cmb@php.net
Well, we're somewhat limited by libzip here. Besides zip_open()
what we're already using to open from a path, there is only
zip_fdopen() which would allow opening from a file descriptor. So
for most protocol wrappers we would need to create a temporary
file, what can be done in userland as well.
> This is important as on RO filesystems zip archives can not be
> currently opened and files like Excel can no be read.
Not even if you pass ZipArchive::OPEN_RDONLY as $flag to ::open()?
------------------------------------------------------------------------
[2020-11-15 21:08:08] michael dot vorisek at email dot cz
Description:
------------
ZipArchive does currently not allow to open archive from string not data URL.
This is a feature request to allow ZipArchive to open archive from string or at least data URL.
This is important as on RO filesystems zip archives can not be currently opened and files like Excel
can no be read.
Test script:
---------------
$dataAsUrl = $imageData = 'data:application/octet-stream;base64,' .
base64_encode($fileData);
$zip = new \ZipArchive();
$zip->open($dataAsUrl);
Expected result:
----------------
ZipArchive object can open/load data from string or from data URL.
Actual result:
--------------
<b>Warning</b>: ZipArchive::open(): File name is longer than the maximum allowed path
length on this platform (4096): data:application/octet-stream;base64,UEsDBBQABgAIAAA
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80372&edit=1
Thread (3 messages)