From dc829b1dc0cbb2c944a277316eed69f32f3a4e6e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Wed, 29 May 2013 15:04:51 +0200 Subject: [PATCH] Improve Zip and ZipWriter see http://beta.woltlab.com/index.php/Thread/1372-ZipWriter-erzeugt-fehlerhafte-Datei/ --- wcfsetup/install/files/lib/system/io/Zip.class.php | 6 +++--- wcfsetup/install/files/lib/system/io/ZipWriter.class.php | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) 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 @@