alchemy-fr / Zippy

PHP zip/tar/bz2 archives (de)compression library with commandline or extensions
Other
470 stars 106 forks source link

Error when only single url passed to create() #157

Open mb-shirtigo opened 4 years ago

mb-shirtigo commented 4 years ago

Hey,

we get a chdir error, when the array contains only one url. With two or more the zip file is generated without any problems.

Error: Alchemy\Zippy\Exception\RuntimeException: Unable to chdir to https://www.google.de/images/branding/googlelogo/2x

NOT WORKING: $file = ['https://www.google.de/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png']; $archiveZip = $zippy->create('archive.zip', $file, false);

WORKING: $file =['https://www.google.de/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png','https://www.google.de/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png']; $archiveZip = $zippy->create('archive.zip', $file, false);

Any help is appreciated.

Kind regards Michael

chriskonnertz commented 4 years ago

Hello,

I investigated and the error seems to be caused by this line of code: return isset($data['path']); https://github.com/alchemy-fr/Zippy/blob/master/src/Resource/Resource.php#L114

Even for a path that is without any doubt NOT local the path index will be set. (You can test this here: http://sandbox.onlinephpfunctions.com/code/29fbfd20b141347ec613740ab7b7b039c95cec1a )

parse_url() does not seem to be the right choice here. I guess the most basic approach would be to check if the path contains "://".