From ddb94cf031c80ef24f90bb47eb325f88a99c3657 Mon Sep 17 00:00:00 2001
From: Andreas Gohr <andi@splitbrain.org>
Date: Tue, 1 May 2018 10:10:27 +0200
Subject: [PATCH] updated php-archive lib. fixes #2361

---
 composer.lock                               |  17 +--
 vendor/composer/installed.json              | 109 ++++++++++----------
 vendor/splitbrain/php-archive/composer.json |  13 ++-
 vendor/splitbrain/php-archive/phpunit.xml   |   7 +-
 vendor/splitbrain/php-archive/src/Tar.php   |  10 +-
 vendor/splitbrain/php-archive/src/Zip.php   |  10 +-
 6 files changed, 94 insertions(+), 72 deletions(-)

diff --git a/composer.lock b/composer.lock
index 8e1fa1770..7ab0304fe 100644
--- a/composer.lock
+++ b/composer.lock
@@ -389,23 +389,26 @@
         },
         {
             "name": "splitbrain/php-archive",
-            "version": "1.0.9",
+            "version": "1.0.10",
             "source": {
                 "type": "git",
                 "url": "https://github.com/splitbrain/php-archive.git",
-                "reference": "2a63b8cf0bfc7fdc0d987c9b7348e639e55cce76"
+                "reference": "a46f3aaeb9f123fdb7db4e192b0600feebf7f773"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/splitbrain/php-archive/zipball/2a63b8cf0bfc7fdc0d987c9b7348e639e55cce76",
-                "reference": "2a63b8cf0bfc7fdc0d987c9b7348e639e55cce76",
+                "url": "https://api.github.com/repos/splitbrain/php-archive/zipball/a46f3aaeb9f123fdb7db4e192b0600feebf7f773",
+                "reference": "a46f3aaeb9f123fdb7db4e192b0600feebf7f773",
                 "shasum": ""
             },
             "require": {
-                "php": ">=5.3.0"
+                "php": ">=5.4"
             },
             "require-dev": {
-                "phpunit/phpunit": "4.5.*"
+                "ext-bz2": "*",
+                "ext-zip": "*",
+                "mikey179/vfsstream": "^1.6",
+                "phpunit/phpunit": "^4.8"
             },
             "suggest": {
                 "ext-iconv": "Used for proper filename encode handling",
@@ -436,7 +439,7 @@
                 "unzip",
                 "zip"
             ],
-            "time": "2017-06-11T06:11:38+00:00"
+            "time": "2018-05-01T08:03:56+00:00"
         },
         {
             "name": "splitbrain/php-cli",
diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json
index eee3a0225..23ae5c1e0 100644
--- a/vendor/composer/installed.json
+++ b/vendor/composer/installed.json
@@ -188,59 +188,6 @@
         "description": "lesserphp is a compiler for LESS written in PHP based on leafo's lessphp.",
         "homepage": "http://leafo.net/lessphp/"
     },
-    {
-        "name": "splitbrain/php-archive",
-        "version": "1.0.9",
-        "version_normalized": "1.0.9.0",
-        "source": {
-            "type": "git",
-            "url": "https://github.com/splitbrain/php-archive.git",
-            "reference": "2a63b8cf0bfc7fdc0d987c9b7348e639e55cce76"
-        },
-        "dist": {
-            "type": "zip",
-            "url": "https://api.github.com/repos/splitbrain/php-archive/zipball/2a63b8cf0bfc7fdc0d987c9b7348e639e55cce76",
-            "reference": "2a63b8cf0bfc7fdc0d987c9b7348e639e55cce76",
-            "shasum": ""
-        },
-        "require": {
-            "php": ">=5.3.0"
-        },
-        "require-dev": {
-            "phpunit/phpunit": "4.5.*"
-        },
-        "suggest": {
-            "ext-iconv": "Used for proper filename encode handling",
-            "ext-mbstring": "Can be used alternatively for handling filename encoding"
-        },
-        "time": "2017-06-11T06:11:38+00:00",
-        "type": "library",
-        "installation-source": "dist",
-        "autoload": {
-            "psr-4": {
-                "splitbrain\\PHPArchive\\": "src"
-            }
-        },
-        "notification-url": "https://packagist.org/downloads/",
-        "license": [
-            "MIT"
-        ],
-        "authors": [
-            {
-                "name": "Andreas Gohr",
-                "email": "andi@splitbrain.org"
-            }
-        ],
-        "description": "Pure-PHP implementation to read and write TAR and ZIP archives",
-        "keywords": [
-            "archive",
-            "extract",
-            "tar",
-            "unpack",
-            "unzip",
-            "zip"
-        ]
-    },
     {
         "name": "paragonie/random_compat",
         "version": "v2.0.12",
@@ -499,5 +446,61 @@
             "x.509",
             "x509"
         ]
+    },
+    {
+        "name": "splitbrain/php-archive",
+        "version": "1.0.10",
+        "version_normalized": "1.0.10.0",
+        "source": {
+            "type": "git",
+            "url": "https://github.com/splitbrain/php-archive.git",
+            "reference": "a46f3aaeb9f123fdb7db4e192b0600feebf7f773"
+        },
+        "dist": {
+            "type": "zip",
+            "url": "https://api.github.com/repos/splitbrain/php-archive/zipball/a46f3aaeb9f123fdb7db4e192b0600feebf7f773",
+            "reference": "a46f3aaeb9f123fdb7db4e192b0600feebf7f773",
+            "shasum": ""
+        },
+        "require": {
+            "php": ">=5.4"
+        },
+        "require-dev": {
+            "ext-bz2": "*",
+            "ext-zip": "*",
+            "mikey179/vfsstream": "^1.6",
+            "phpunit/phpunit": "^4.8"
+        },
+        "suggest": {
+            "ext-iconv": "Used for proper filename encode handling",
+            "ext-mbstring": "Can be used alternatively for handling filename encoding"
+        },
+        "time": "2018-05-01T08:03:56+00:00",
+        "type": "library",
+        "installation-source": "dist",
+        "autoload": {
+            "psr-4": {
+                "splitbrain\\PHPArchive\\": "src"
+            }
+        },
+        "notification-url": "https://packagist.org/downloads/",
+        "license": [
+            "MIT"
+        ],
+        "authors": [
+            {
+                "name": "Andreas Gohr",
+                "email": "andi@splitbrain.org"
+            }
+        ],
+        "description": "Pure-PHP implementation to read and write TAR and ZIP archives",
+        "keywords": [
+            "archive",
+            "extract",
+            "tar",
+            "unpack",
+            "unzip",
+            "zip"
+        ]
     }
 ]
diff --git a/vendor/splitbrain/php-archive/composer.json b/vendor/splitbrain/php-archive/composer.json
index 36c649769..bdc2e02a9 100644
--- a/vendor/splitbrain/php-archive/composer.json
+++ b/vendor/splitbrain/php-archive/composer.json
@@ -11,7 +11,7 @@
     "license": "MIT",
 
     "require": {
-        "php": ">=5.3.0"
+        "php": ">=5.4"
     },
 
     "suggest": {
@@ -20,12 +20,21 @@
     },
 
     "require-dev": {
-        "phpunit/phpunit": "4.5.*"
+        "phpunit/phpunit": "^4.8",
+        "mikey179/vfsStream": "^1.6",
+        "ext-zip": "*",
+        "ext-bz2": "*"
     },
 
     "autoload": {
         "psr-4": {
             "splitbrain\\PHPArchive\\": "src"
         }
+    },
+
+    "autoload-dev": {
+        "psr-4": {
+            "splitbrain\\PHPArchive\\": "tests"
+        }
     }
 }
diff --git a/vendor/splitbrain/php-archive/phpunit.xml b/vendor/splitbrain/php-archive/phpunit.xml
index d7e1f2428..c5e1ad3ce 100644
--- a/vendor/splitbrain/php-archive/phpunit.xml
+++ b/vendor/splitbrain/php-archive/phpunit.xml
@@ -14,4 +14,9 @@
             <directory suffix=".php">./tests/</directory>
         </testsuite>
     </testsuites>
-</phpunit>
\ No newline at end of file
+    <filter>
+        <whitelist processUncoveredFilesFromWhitelist="false">
+            <directory suffix=".php">src</directory>
+        </whitelist>
+    </filter>
+</phpunit>
diff --git a/vendor/splitbrain/php-archive/src/Tar.php b/vendor/splitbrain/php-archive/src/Tar.php
index b25575854..5f01f39bd 100644
--- a/vendor/splitbrain/php-archive/src/Tar.php
+++ b/vendor/splitbrain/php-archive/src/Tar.php
@@ -164,7 +164,7 @@ class Tar extends Archive
 
             // extract data
             if (!$fileinfo->getIsdir()) {
-                $fp = fopen($output, "wb");
+                $fp = @fopen($output, "wb");
                 if (!$fp) {
                     throw new ArchiveIOException('Could not open file for writing: '.$output);
                 }
@@ -245,7 +245,7 @@ class Tar extends Archive
             throw new ArchiveIOException('Archive has been closed, files can no longer be added');
         }
 
-        $fp = fopen($file, 'rb');
+        $fp = @fopen($file, 'rb');
         if (!$fp) {
             throw new ArchiveIOException('Could not open file for reading: '.$file);
         }
@@ -379,7 +379,7 @@ class Tar extends Archive
             $this->setCompression($this->complevel, $this->filetype($file));
         }
 
-        if (!file_put_contents($file, $this->getArchive())) {
+        if (!@file_put_contents($file, $this->getArchive())) {
             throw new ArchiveIOException('Could not write to file: '.$file);
         }
     }
@@ -433,7 +433,7 @@ class Tar extends Archive
      *
      * @param int $bytes seek to this position
      */
-    function skipbytes($bytes)
+    protected function skipbytes($bytes)
     {
         if ($this->comptype === Archive::COMPRESS_GZIP) {
             @gzseek($this->fh, $bytes, SEEK_CUR);
@@ -645,7 +645,7 @@ class Tar extends Archive
     {
         // for existing files, try to read the magic bytes
         if(file_exists($file) && is_readable($file) && filesize($file) > 5) {
-            $fh = fopen($file, 'rb');
+            $fh = @fopen($file, 'rb');
             if(!$fh) return false;
             $magic = fread($fh, 5);
             fclose($fh);
diff --git a/vendor/splitbrain/php-archive/src/Zip.php b/vendor/splitbrain/php-archive/src/Zip.php
index 272a9027b..e84516b63 100644
--- a/vendor/splitbrain/php-archive/src/Zip.php
+++ b/vendor/splitbrain/php-archive/src/Zip.php
@@ -111,7 +111,7 @@ class Zip extends Archive
      * @throws ArchiveIOException
      * @return FileInfo[]
      */
-    function extract($outdir, $strip = '', $exclude = '', $include = '')
+    public function extract($outdir, $strip = '', $exclude = '', $include = '')
     {
         if ($this->closed || !$this->file) {
             throw new ArchiveIOException('Can not read from a closed archive');
@@ -163,7 +163,7 @@ class Zip extends Archive
             }
 
             // open file for writing
-            $fp = fopen($extractto, "wb");
+            $fp = @fopen($extractto, "wb");
             if (!$fp) {
                 throw new ArchiveIOException('Could not open file for writing: '.$extractto);
             }
@@ -419,7 +419,7 @@ class Zip extends Archive
      */
     public function save($file)
     {
-        if (!file_put_contents($file, $this->getArchive())) {
+        if (!@file_put_contents($file, $this->getArchive())) {
             throw new ArchiveIOException('Could not write to file: '.$file);
         }
     }
@@ -629,12 +629,14 @@ class Zip extends Archive
      * similar enough. CP437 seems not to be available in mbstring. Lastly falls back to keeping the
      * string as is, which is still better than nothing.
      *
+     * On some systems iconv is available, but the codepage is not. We also check for that.
+     *
      * @param $string
      * @return string
      */
     protected function cpToUtf8($string)
     {
-        if (function_exists('iconv')) {
+        if (function_exists('iconv') && @iconv_strlen('', 'CP437') !== false) {
             return iconv('CP437', 'UTF-8', $string);
         } elseif (function_exists('mb_convert_encoding')) {
             return mb_convert_encoding($string, 'UTF-8', 'CP850');
-- 
GitLab