Fix out-of-root path detection logic

This commit is contained in:
Exter-N 2025-02-03 00:20:22 +01:00
parent ec09a7eb0e
commit d303e0c8b2

View file

@ -25,6 +25,8 @@ public class ResourceTreeFactory(
PathState pathState,
ModManager modManager) : IService
{
private static readonly string ParentDirectoryPrefix = $"..{Path.DirectorySeparatorChar}";
private TreeBuildCache CreateTreeBuildCache()
=> new(objects, gameData, actors);
@ -159,7 +161,7 @@ public class ResourceTreeFactory(
if (onlyWithinPath != null)
{
var relPath = Path.GetRelativePath(onlyWithinPath, fullPath.FullName);
if (relPath != "." && (relPath.StartsWith('.') || Path.IsPathRooted(relPath)))
if (relPath == ".." || relPath.StartsWith(ParentDirectoryPrefix) || Path.IsPathRooted(relPath))
return false;
}