From 981c2bace4d32c404447a14c95e7129ff4212163 Mon Sep 17 00:00:00 2001 From: Exter-N Date: Mon, 3 Feb 2025 00:20:22 +0100 Subject: [PATCH] Fix out-of-root path detection logic --- Penumbra/Interop/ResourceTree/ResourceTreeFactory.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Penumbra/Interop/ResourceTree/ResourceTreeFactory.cs b/Penumbra/Interop/ResourceTree/ResourceTreeFactory.cs index f5659e7c..95627566 100644 --- a/Penumbra/Interop/ResourceTree/ResourceTreeFactory.cs +++ b/Penumbra/Interop/ResourceTree/ResourceTreeFactory.cs @@ -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; }