changed.对启动器重构的尝试

This commit is contained in:
lincube
2026-05-28 15:14:37 +08:00
parent 1ef47c780b
commit 313d093257
51 changed files with 4509 additions and 2478 deletions

View File

@@ -0,0 +1,20 @@
namespace LanMountainDesktop.Launcher.Update;
internal static class UpdatePathGuard
{
public static string NormalizeRelativePath(string path)
{
var normalized = path.Replace('\\', Path.DirectorySeparatorChar).Replace('/', Path.DirectorySeparatorChar);
return normalized.TrimStart(Path.DirectorySeparatorChar);
}
public static void EnsurePathWithinRoot(string targetPath, string rootPath)
{
var fullTarget = Path.GetFullPath(targetPath);
var fullRoot = Path.GetFullPath(rootPath);
if (!fullTarget.StartsWith(fullRoot, StringComparison.OrdinalIgnoreCase))
{
throw new InvalidOperationException($"Path traversal detected: {targetPath}");
}
}
}