@@ -85,24 +85,12 @@ public string GetResolvedCachePath()
8585 var config = ReadConfig ( ) ;
8686 var rawPath = string . IsNullOrWhiteSpace ( config . CachePath ) ? DefaultCacheRelativePath : config . CachePath ;
8787
88- if ( ContainsParentTraversal ( rawPath ) )
89- {
90- throw new InvalidOperationException ( "MuMod cache path cannot contain '..'" ) ;
91- }
92-
9388 var expandedPath = Environment . ExpandEnvironmentVariables ( rawPath . Trim ( ) ) ;
9489 var candidate = Path . IsPathRooted ( expandedPath )
9590 ? expandedPath
9691 : Path . Combine ( StaticSettings . GamePath , expandedPath ) ;
9792
98- var fullPath = Path . GetFullPath ( candidate ) ;
99- var gameRoot = Path . GetFullPath ( StaticSettings . GamePath ) ;
100- if ( ! IsPathInsideRoot ( fullPath , gameRoot ) )
101- {
102- throw new InvalidOperationException ( $ "MuMod cache path escapes game directory: { fullPath } ") ;
103- }
104-
105- return fullPath ;
93+ return Path . GetFullPath ( candidate ) ;
10694 }
10795
10896 public async Task < EnsureCacheResult > EnsureCache ( CancellationToken ct = default )
@@ -189,19 +177,6 @@ public bool IsMuModInstalled()
189177 return File . Exists ( ModPaths . MuModDllInstalledPath ) ? ReadProductVersion ( ModPaths . MuModDllInstalledPath ) : null ;
190178 }
191179
192- private static bool ContainsParentTraversal ( string path )
193- {
194- var segments = path . Split ( [ Path . DirectorySeparatorChar , Path . AltDirectorySeparatorChar ] , StringSplitOptions . RemoveEmptyEntries ) ;
195- return segments . Any ( segment => segment == ".." ) ;
196- }
197-
198- private static bool IsPathInsideRoot ( string fullPath , string rootPath )
199- {
200- var normalizedRoot = rootPath . TrimEnd ( Path . DirectorySeparatorChar , Path . AltDirectorySeparatorChar ) + Path . DirectorySeparatorChar ;
201- return fullPath . StartsWith ( normalizedRoot , StringComparison . OrdinalIgnoreCase )
202- || string . Equals ( fullPath , rootPath . TrimEnd ( Path . DirectorySeparatorChar , Path . AltDirectorySeparatorChar ) , StringComparison . OrdinalIgnoreCase ) ;
203- }
204-
205180 private static string ResolveApiType ( string channel )
206181 {
207182 return channel switch
0 commit comments