mirror of
https://github.com/michalcz10/USB-RAID-Array.git
synced 2026-11-11 16:09:03 +00:00
Fix SFTP root navigation on Windows
Use portable POSIX parent paths instead of platform-dependent dirname() for remote navigation, previews, uploads, file operations and shared URLs. Normalize browser paths, avoid doubled root separators and preserve top-level directory names in ZIP downloads. Add regression coverage for root navigation, generated links, relative paths and ZIP members, and document the new test command. Verified with PHP syntax checks and all three regression suites.
This commit is contained in:
+1
-13
@@ -3,6 +3,7 @@
|
||||
|
||||
// Autoload dependencies (phpseclib)
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
require_once __DIR__ . '/../includes/remotepaths.php';
|
||||
|
||||
use phpseclib3\Net\SFTP;
|
||||
use phpseclib3\Net\SSH2;
|
||||
@@ -56,17 +57,4 @@ function getSSHConnection(): SSH2 {
|
||||
return $ssh;
|
||||
}
|
||||
|
||||
/** Utility: Normalise a path */
|
||||
function normalizePath(string $path): string {
|
||||
$parts = array_filter(explode('/', $path), fn($part) => $part !== '' && $part !== '.');
|
||||
$stack = [];
|
||||
foreach ($parts as $part) {
|
||||
if ($part === '..') {
|
||||
array_pop($stack);
|
||||
} else {
|
||||
$stack[] = $part;
|
||||
}
|
||||
}
|
||||
return '/' . implode('/', $stack);
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user