From f3bdc8328d140b988ba7099a87342ebb8e1f417d 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 | 4 ++-- lib/Updater.php | 4 ++-- tests/checkSameCodeBase.php | 2 +- updater.phar | Bin 1325431 -> 1325443 bytes 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/index.php b/index.php index ccba6572..1022397b 100644 --- a/index.php +++ b/index.php @@ -507,7 +507,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 @@ -1178,7 +1178,7 @@ private function moveWithExclusions(string $dataLocation, array $excludedElement } - $fileName = explode($dataLocation, $path)[1]; + $fileName = explode($dataLocation, $path, 2)[1]; if ($fileInfo->isFile()) { if (!file_exists($this->nextcloudDir . '/' . dirname($fileName))) { diff --git a/lib/Updater.php b/lib/Updater.php index b4bd947b..331cddb7 100644 --- a/lib/Updater.php +++ b/lib/Updater.php @@ -491,7 +491,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 @@ -1162,7 +1162,7 @@ private function moveWithExclusions(string $dataLocation, array $excludedElement } - $fileName = explode($dataLocation, $path)[1]; + $fileName = explode($dataLocation, $path, 2)[1]; if ($fileInfo->isFile()) { if (!file_exists($this->nextcloudDir . '/' . dirname($fileName))) { diff --git a/tests/checkSameCodeBase.php b/tests/checkSameCodeBase.php index bd1d2c8a..fb106b60 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)) { continue; diff --git a/updater.phar b/updater.phar index 4d801ff5e48c349e3f7dd8ce7a724d908222c478..d17a3ca1beedfa8fed9bed7db752397dfa2f5ae5 100755 GIT binary patch delta 323 zcmezVDWLgtz=ZicrYXs$W=2V7Nv5Xe6IUAxA@lVLG7^jQCoi;AUAw0Rjqrxgf!+PDEZLW)Zv~7CbW~?YHXw?4v z=6k+ax16om@>ijf0?e~!S#1?{o9|KCVXVDk?h5&|_e%nH@R=p8bmjTY0`!f$ldls1 D<;P?& delta 309 zcmZqv9Ps^9z=ZicCT3{{CWdLrhRJEh6IUAxA@lVLG7^jQCoi;mxBG38rUM^hl*)Vi#H2JYx=YuKBb`?Zush ul7;j3 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 Signed-off-by: Côme Chilliet --- index.php | 10 ++++++++-- lib/Updater.php | 10 ++++++++-- updater.phar | Bin 1325443 -> 1325696 bytes 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/index.php b/index.php index 1022397b..62bb6885 100644 --- a/index.php +++ b/index.php @@ -507,7 +507,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 @@ -1178,7 +1181,10 @@ private function moveWithExclusions(string $dataLocation, array $excludedElement } - $fileName = explode($dataLocation, $path, 2)[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 331cddb7..00360a41 100644 --- a/lib/Updater.php +++ b/lib/Updater.php @@ -491,7 +491,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 @@ -1162,7 +1165,10 @@ private function moveWithExclusions(string $dataLocation, array $excludedElement } - $fileName = explode($dataLocation, $path, 2)[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/updater.phar b/updater.phar index d17a3ca1beedfa8fed9bed7db752397dfa2f5ae5..0373fe055eaa6bb70a2c895954c40585e7ad55d9 100755 GIT binary patch delta 504 zcmZqv9MJGJV8VRvM01O@L=#hUbCcAGt4xHDxaN8V8Hq*ulNZ{_Pv&QIMpijFmeCHG zzj+xWlbb+30|bER4-$LVPTt|}Eih{>L=Z%)u3lExEbP%P?7;}cOhC*G#4JF}3dC$c z%nrmHK+FlmTtLhX#5_RE3&eat%n!r@KrFaj*h9$v3%99my1Aioa&mI2`t*j^!Uwi1 z+X`2jsw>#rE98~tI_F~v>}zD%);xWEsK59F&)KE#0&j2{796w>aaEdL&ofiu p>T%zD7xULVo@yoahJHP>)K`1nBNkvRxI6he0RTi|qip~H delta 316 zcmZqp8qoYXV8VQE)0AXWGovK4BvaFgt4xHDxaN8V8Hq*ulNZ{_Pv&QIMpijFmeCHG zzj+xWlbb*(0|bERu*q$!Chu_f7MQ*UA_$_TZA{iT3wyK+doThq6A&{4F$)m00x=s9 zvjZ^)5OV@C7Z7s;F%J;)0x=&D^8>K}5DRV>_7JlFB4DhWo?>ohZjffKkdj$cQn@|G zM%c=X(R#Z`u`qualQq}$1v`aBw;wnuTv6arVU?j_y>8An*Tp^BHoa~$R+JSqYJYz7 zJzuO_&Q@&st58V+=2^3>wu-vV_o(bJ)?P7pg?!rkB>_A5%#v2R^8982`o!JI*9icf C_h9q@