21 throw new \Magento\Framework\Exception\LocalizedException(
37 $zip = new \ZipArchive();
38 $zip->open($destination, \ZipArchive::CREATE);
54 $zip = new \ZipArchive();
55 if ($zip->open(
$source) ===
true) {
56 $filename = $this->filterRelativePaths($zip->getNameIndex(0) ?:
'');
58 $zip->extractTo(dirname($destination), $filename);
59 rename(dirname($destination).
'/'.$filename, $destination);
77 private function filterRelativePaths(
string $path): string
79 if (
$path && preg_match(
'#^\s*(../)|(/../)#i',
$path)) {
pack($source, $destination)
unpack($source, $destination)