mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Fix subpath check
This commit is contained in:
parent
383298a46b
commit
a6b7c5898b
1 changed files with 13 additions and 1 deletions
|
|
@ -8,6 +8,7 @@ using System.Linq;
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Flow.Launcher.Plugin.Explorer.Exceptions;
|
||||
using System.IO;
|
||||
|
||||
namespace Flow.Launcher.Plugin.Explorer.Search
|
||||
{
|
||||
|
|
@ -119,7 +120,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
|||
}
|
||||
|
||||
results.RemoveWhere(r => Settings.IndexSearchExcludedSubdirectoryPaths.Any(
|
||||
excludedPath => r.SubTitle.StartsWith(excludedPath.Path, StringComparison.OrdinalIgnoreCase)));
|
||||
excludedPath => IsSubPathOf(r.SubTitle, excludedPath.Path)));
|
||||
|
||||
return results.ToList();
|
||||
}
|
||||
|
|
@ -254,5 +255,16 @@ namespace Flow.Launcher.Plugin.Explorer.Search
|
|||
&& search != "%%"
|
||||
&& !search.Contains('\\');
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/a/66877016
|
||||
internal static bool IsSubPathOf(string subPath, string basePath)
|
||||
{
|
||||
var rel = Path.GetRelativePath(basePath, subPath);
|
||||
return rel != "."
|
||||
&& rel != ".."
|
||||
&& !rel.StartsWith("../")
|
||||
&& !rel.StartsWith(@"..\")
|
||||
&& !Path.IsPathRooted(rel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue