Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed issue #17303: ZipArchive error when exporting theme and debug m…
…ode is avtive
  • Loading branch information
c-schmitz committed May 18, 2021
1 parent 85e16c6 commit 532fc97
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 150 deletions.
2 changes: 1 addition & 1 deletion application/controllers/admin/themes.php
Expand Up @@ -50,7 +50,7 @@ public function templatezip($templatename)

$zipfile = "$tempdir/$templatename.zip";
Yii::app()->loadLibrary('admin.pclzip');
$zip = new PclZip($zipfile);
$zip = new PclZip($zipfile, false);
$zip->create($templatedir, PCLZIP_OPT_REMOVE_PATH, $oEditedTemplate->path);

if (is_file($zipfile)) {
Expand Down
148 changes: 0 additions & 148 deletions application/core/web/LSYii_SecurityManager.php

This file was deleted.

13 changes: 12 additions & 1 deletion application/helpers/common_helper.php
Expand Up @@ -4928,7 +4928,18 @@ function crypto_rand_secure($min, $max)
*/
function isZipBomb($zip_filename)
{
return ( get_zip_originalsize($zip_filename) > Yii::app()->getConfig('maximum_unzipped_size') );
$totalSize = 0;
$zip = new ZipArchive();
if ($zip->open($zip_filename) === true) {

for ($i = 0; $i < $zip->numFiles; $i++) {
$fileStats = $zip->statIndex($i);
$totalSize += $fileStats['size'];
}

$zip->close();
}
return ( $totalSize > Yii::app()->getConfig('maximum_unzipped_size'));
}

/**
Expand Down

0 comments on commit 532fc97

Please sign in to comment.