diff --git a/index.php b/index.php index 2beb3fb2..1b993a25 100644 --- a/index.php +++ b/index.php @@ -508,7 +508,10 @@ public function createBackup(): void { } foreach ($this->getRecursiveDirectoryIterator($this->nextcloudDir, $excludedElements) as $absolutePath => $fileInfo) { - $relativePath = explode($this->nextcloudDir, $absolutePath)[1]; + $relativePath = explode($this->nextcloudDir, $absolutePath, 2)[1] ?? null; + if ($relativePath === null) { + throw new \Exception($absolutePath . ' is not in ' . $this->nextcloudDir); + } $relativeDirectory = dirname($relativePath); // Create folder if it doesn't exist @@ -1180,7 +1183,10 @@ private function moveWithExclusions(string $dataLocation, array $excludedElement } - $fileName = explode($dataLocation, $path)[1]; + $fileName = explode($dataLocation, $path, 2)[1] ?? null; + if ($fileName === null) { + throw new \Exception('Could not move ' . $path . ' as it’s not in ' . $dataLocation); + } if ($fileInfo->isFile()) { if (!file_exists($this->nextcloudDir . '/' . dirname($fileName))) { diff --git a/lib/Updater.php b/lib/Updater.php index 665b3a14..96322949 100644 --- a/lib/Updater.php +++ b/lib/Updater.php @@ -492,7 +492,10 @@ public function createBackup(): void { } foreach ($this->getRecursiveDirectoryIterator($this->nextcloudDir, $excludedElements) as $absolutePath => $fileInfo) { - $relativePath = explode($this->nextcloudDir, $absolutePath)[1]; + $relativePath = explode($this->nextcloudDir, $absolutePath, 2)[1] ?? null; + if ($relativePath === null) { + throw new \Exception($absolutePath . ' is not in ' . $this->nextcloudDir); + } $relativeDirectory = dirname($relativePath); // Create folder if it doesn't exist @@ -1164,7 +1167,10 @@ private function moveWithExclusions(string $dataLocation, array $excludedElement } - $fileName = explode($dataLocation, $path)[1]; + $fileName = explode($dataLocation, $path, 2)[1] ?? null; + if ($fileName === null) { + throw new \Exception('Could not move ' . $path . ' as it’s not in ' . $dataLocation); + } if ($fileInfo->isFile()) { if (!file_exists($this->nextcloudDir . '/' . dirname($fileName))) { diff --git a/tests/checkSameCodeBase.php b/tests/checkSameCodeBase.php index 0f87c3dd..703a800a 100644 --- a/tests/checkSameCodeBase.php +++ b/tests/checkSameCodeBase.php @@ -56,7 +56,7 @@ function findDiffPos($original, $copy) { * @var SplFileInfo $fileInfo */ foreach ($iterator as $path => $fileInfo) { - $fileName = explode($libDir, $path)[1]; + $fileName = explode($libDir, $path, 2)[1]; if (in_array($fileName, $excludedFiles, true)) { continue; diff --git a/updater.phar b/updater.phar index 625fae13..e4189936 100755 Binary files a/updater.phar and b/updater.phar differ diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 99b12393..b00be49f 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -3,7 +3,7 @@ 'name' => '__root__', 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => '4123450c26d24ffaa60b2b495e0d8aa934cd982e', + 'reference' => 'aa4d3f66efadf70396c0ab758da5d105bade36e2', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -13,7 +13,7 @@ '__root__' => array( 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => '4123450c26d24ffaa60b2b495e0d8aa934cd982e', + 'reference' => 'aa4d3f66efadf70396c0ab758da5d105bade36e2', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(),