mirror of
https://github.com/michalcz10/USB-RAID-Array.git
synced 2026-11-11 07:59:04 +00:00
revise backend
This commit is contained in:
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user