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
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
Have you experienced this issue?
Rate the importance of this bug to you:

 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2021 The PHP Group
All rights reserved.
Last updated: Fri Jan 22 17:01:23 2021 UTC