From: Tim Düsterhus Date: Wed, 29 May 2013 13:04:51 +0000 (+0200) Subject: Improve Zip and ZipWriter X-Git-Tag: 2.0.0_Beta_1~2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=dc829b1dc0cbb2c944a277316eed69f32f3a4e6e;p=GitHub%2FWoltLab%2FWCF.git Improve Zip and ZipWriter see http://beta.woltlab.com/index.php/Thread/1372-ZipWriter-erzeugt-fehlerhafte-Datei/ --- diff --git a/wcfsetup/install/files/lib/system/io/Zip.class.php b/wcfsetup/install/files/lib/system/io/Zip.class.php index 2950ed4637..18be9bfbcf 100644 --- a/wcfsetup/install/files/lib/system/io/Zip.class.php +++ b/wcfsetup/install/files/lib/system/io/Zip.class.php @@ -177,10 +177,10 @@ class Zip extends File implements IArchive { $data['mtime'] = mktime($hour, $minute, $second, $month, $day, $year); $data += unpack('Vcrc32/VcompressedSize/Vsize/vfilenameLength/vextraFieldLength/vfileCommentLength/vdiskNo/vinternalAttr/vexternalAttr', $this->read(26)); - if ($data['compressedSize'] > 0) $data['type'] = 'file'; - else $data['type'] = 'folder'; $data['offset'] = $this->readAndUnpack(4, 'v'); $data['filename'] = $this->read($data['filenameLength']); + if (substr($data['filename'], -1) == '/') $data['type'] = 'folder'; + else $data['type'] = 'file'; // read extraField if ($data['extraFieldLength'] > 0) $data['extraField'] = $this->read($data['extraFieldLength']); @@ -295,7 +295,7 @@ class Zip extends File implements IArchive { // read contents $header['type'] = 'file'; - if ($header['compressedSize'] > 0) $content = $this->read($header['compressedSize']); + if (substr($header['filename'], -1) != '/') $content = $this->read($header['compressedSize']); else { $header['type'] = 'folder'; $content = false; diff --git a/wcfsetup/install/files/lib/system/io/ZipWriter.class.php b/wcfsetup/install/files/lib/system/io/ZipWriter.class.php index d56ac10a1e..18a520a807 100644 --- a/wcfsetup/install/files/lib/system/io/ZipWriter.class.php +++ b/wcfsetup/install/files/lib/system/io/ZipWriter.class.php @@ -1,5 +1,6 @@