From c5d1b4eaee7639eab23672da0c922de99c604aa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Thu, 28 May 2026 11:09:06 +0200 Subject: [PATCH 1/2] fix: Fix explode calls for path parsing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Always pass a limit of 2 when using explode in this way avoids bugs when the path contains several times the delimiter by chance. Signed-off-by: Côme Chilliet --- index.php | 2 +- lib/Updater.php | 2 +- tests/checkSameCodeBase.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/index.php b/index.php index 6a458797..7ea4c89e 100644 --- a/index.php +++ b/index.php @@ -448,7 +448,7 @@ 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]; $relativeDirectory = dirname($relativePath); // Create folder if it doesn't exist diff --git a/lib/Updater.php b/lib/Updater.php index d3927a05..2c0310c2 100644 --- a/lib/Updater.php +++ b/lib/Updater.php @@ -431,7 +431,7 @@ 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]; $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; From 3538b39bb162e9736e30383561011335a97d0a20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Thu, 28 May 2026 11:37:48 +0200 Subject: [PATCH 2/2] fix: Add error handling and rebuild updater.phar with correct box version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix: Add error handling and rebuild updater.phar with correct box version Signed-off-by: Côme Chilliet [skip ci] --- index.php | 5 ++++- lib/Updater.php | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/index.php b/index.php index 7ea4c89e..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, 2)[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 2c0310c2..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, 2)[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