Fixed an compatibility issue with PHP 7
authorAlexander Ebert <ebert@woltlab.com>
Tue, 6 Jun 2017 11:27:56 +0000 (13:27 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 6 Jun 2017 11:27:56 +0000 (13:27 +0200)
See db8aa273d6eec8f364800681daf3e0a74cb2a624

wcfsetup/install.php

index 958d4e263a83163f4cdcfeee791ee460844b881a..827262db6d363e6034c225dd96e6692c1fd26c5e 100644 (file)
@@ -585,15 +585,32 @@ class Tar {
                $i = 0;
                
                // Read the 512 bytes header
+               $longFilename = null;
                while (strlen($binaryData = $this->file->read(512)) != 0) {
                        // read header
                        $header = $this->readHeader($binaryData);
                        if ($header === false) {
                                continue;
                        }
-                       $this->contentList[$i] = $header;
-                       $this->contentList[$i]['index'] = $i;
-                       $i++;
+                       // fixes a bug that files with long names aren't correctly
+                       // extracted
+                       if ($longFilename !== null) {
+                               $header['filename'] = $longFilename;
+                               $longFilename = null;
+                       }
+                       if ($header['typeflag'] == 'L') {
+                               $format = 'Z' . $header['size'] . 'filename';
+                               
+                               $fileData = unpack($format, $this->file->read(512));
+                               $longFilename = $fileData['filename'];
+                               $header['size'] = 0;
+                       }
+                       // don't include the @LongLink file in the content list
+                       else {
+                               $this->contentList[$i] = $header;
+                               $this->contentList[$i]['index'] = $i;
+                               $i++;
+                       }
                        
                        $this->file->seek($this->file->tell() + (512 * ceil(($header['size'] / 512))));
                }