fix: canonicalize legacy drive aliases in resolved paths
This commit is contained in:
@@ -36,6 +36,12 @@ public sealed class PathResolver(IReadOnlyDictionary<string, string?>? environme
|
||||
{
|
||||
var resolved = new Dictionary<string, string?>(StringComparer.OrdinalIgnoreCase);
|
||||
foreach (var name in variables.Values.Keys) resolved[name] = ResolveVariable(name, variables, resolved, []);
|
||||
foreach (var name in resolved.Keys.ToArray())
|
||||
if (resolved[name] is { } value && value.StartsWith("A:\\", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var corporate = ResolveVariable(LauncherPathVariableNames.CorporateDfsRoot, variables, resolved, []) ?? throw new InvalidOperationException("PATH_VARIABLE_EMPTY:CorporateDfsRoot");
|
||||
resolved[name] = Path.Combine(corporate, value[3..]);
|
||||
}
|
||||
foreach (var name in required ?? [])
|
||||
if (!resolved.TryGetValue(name, out var value) || string.IsNullOrWhiteSpace(value))
|
||||
throw new InvalidOperationException($"PATH_VARIABLE_REQUIRED:{name}");
|
||||
@@ -47,12 +53,12 @@ public sealed class PathResolver(IReadOnlyDictionary<string, string?>? environme
|
||||
var resolved = Expand(value, variables, new Dictionary<string, string?>(StringComparer.OrdinalIgnoreCase), []);
|
||||
if (string.IsNullOrWhiteSpace(resolved) || !Path.IsPathFullyQualified(resolved))
|
||||
throw new InvalidOperationException("PATH_ABSOLUTE_REQUIRED");
|
||||
var full = Path.GetFullPath(resolved);
|
||||
if (full.StartsWith("A:\\", StringComparison.OrdinalIgnoreCase))
|
||||
if (resolved.StartsWith("A:\\", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var corporate = Resolve(variables, ["CorporateDfsRoot"]).Require("CorporateDfsRoot");
|
||||
full = Path.Combine(corporate, full[3..]);
|
||||
var corporate = Resolve(variables, [LauncherPathVariableNames.CorporateDfsRoot]).Require(LauncherPathVariableNames.CorporateDfsRoot);
|
||||
resolved = Path.Combine(corporate, resolved[3..]);
|
||||
}
|
||||
var full = Path.GetFullPath(resolved);
|
||||
if (full.StartsWith("A:\\", StringComparison.OrdinalIgnoreCase)) throw new InvalidOperationException("LEGACY_DRIVE_A_UNRESOLVED");
|
||||
if (!string.IsNullOrWhiteSpace(constrainedRoot))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user