revise backend

This commit is contained in:
Michal Sedlák
2026-10-18 15:55:34 +02:00
parent dc452059f3
commit 99b1c96f4b
23 changed files with 681 additions and 720 deletions
+15 -1
View File
@@ -28,4 +28,18 @@ foreach (['/etc' => '/etc/config.txt', '/mnt/raid' => '/mnt/raid/config.txt'] as
$relative = substr($file, strlen(rtrim(remoteDirname($base), '/')) + 1);
if ($relative !== ($base === '/etc' ? 'etc/config.txt' : 'raid/config.txt')) throw new RuntimeException('Incorrect ZIP member path');
}
echo "Remote paths: POSIX parents, normalization, root navigation and ZIP paths passed.\n";
foreach ([
['/mnt/raid', '/mnt/raid', true],
['/mnt/raid/folder', '/mnt/raid/', true],
['/mnt/raid-other/file', '/mnt/raid', false],
['/mnt/raid/../private', '/mnt/raid', false],
['/mnt/raid/sub/../../private', '/mnt/raid', false],
['/mnt/raid/sub/../file', '/mnt/raid', true],
['/etc', '/', true],
] as [$path, $basePath, $expected]) {
if (isRemotePathWithin($path, $basePath) !== $expected) throw new RuntimeException('Incorrect path boundary: ' . $path);
}
foreach (['' => false, '.' => false, '..' => false, 'a/b' => false, "a\0b" => false, 'file.txt' => true, '0' => true, 'a\\b' => true] as $name => $expected) {
if (isRemoteNameValid((string) $name) !== $expected) throw new RuntimeException('Incorrect filename validation');
}
echo "Remote paths: POSIX parents, normalization, workspace boundaries, names and ZIP paths passed.\n";