diff --git a/index.php b/index.php index 6a458797..6e67e855 100644 --- a/index.php +++ b/index.php @@ -448,7 +448,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 diff --git a/lib/Updater.php b/lib/Updater.php index d3927a05..b4799183 100644 --- a/lib/Updater.php +++ b/lib/Updater.php @@ -431,7 +431,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 diff --git a/tests/checkSameCodeBase.php b/tests/checkSameCodeBase.php index 400a11c5..969747e7 100644 --- a/tests/checkSameCodeBase.php +++ b/tests/checkSameCodeBase.php @@ -55,7 +55,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 (array_search($fileName, $excludedFiles) !== false) { continue;