From 990b9c148cd2ef1432699d43aebd495126b0c031 Mon Sep 17 00:00:00 2001 From: Blake Niemyjski Date: Thu, 26 Sep 2024 21:36:53 -0500 Subject: [PATCH] Fixed the regex to properly handle different directory patterns passed into the create directory --- src/Foundatio.Storage.SshNet/Storage/SshNetFileStorage.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Foundatio.Storage.SshNet/Storage/SshNetFileStorage.cs b/src/Foundatio.Storage.SshNet/Storage/SshNetFileStorage.cs index 6f595f9..1c1a28c 100644 --- a/src/Foundatio.Storage.SshNet/Storage/SshNetFileStorage.cs +++ b/src/Foundatio.Storage.SshNet/Storage/SshNetFileStorage.cs @@ -524,6 +524,7 @@ private SearchCriteria GetRequestCriteria(string searchPattern) string prefix; Regex patternRegex; + // NOTE: Prefix has to be a directory path, so if we do have a wildcard it needs to be part of the pattern. if (hasWildcard) { patternRegex = new Regex($"^{Regex.Escape(normalizedSearchPattern).Replace("\\*", ".*?")}$"); @@ -533,7 +534,7 @@ private SearchCriteria GetRequestCriteria(string searchPattern) } else { - patternRegex = new Regex($"^{normalizedSearchPattern}$"); + patternRegex = new Regex($"^{Regex.Escape(normalizedSearchPattern)}.*?$"); int slashPos = normalizedSearchPattern.LastIndexOf('/'); prefix = slashPos >= 0 ? normalizedSearchPattern[..slashPos] : String.Empty; }