php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #80372 Allow ZipArchive to open archive from string or at least data URL
Submitted: 2020-11-15 21:08 UTC Modified: 2020-11-17 12:36 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: michael dot vorisek at email dot cz Assigned:
Status: Open Package: Zip Related
PHP Version: 7.4.12 OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: michael dot vorisek at email dot cz
New email:
PHP Version: OS:

 

 [2020-11-15 21:08 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-11-17 12:36 UTC] 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-17 15:01 UTC] 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 15:04 UTC] michael dot vorisek at email dot cz
Good news - it should be possible!

https://github.com/nih-at/libzip/issues/220
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 18:01:29 2024 UTC