diff --git a/TextFilter.Test/TextFilterTests.cs b/TextFilter.Test/TextFilterTests.cs index 3250a64..3d72e01 100644 --- a/TextFilter.Test/TextFilterTests.cs +++ b/TextFilter.Test/TextFilterTests.cs @@ -1004,6 +1004,8 @@ public void ExpandGlobClassesRejectsClassesThatCannotBeListed(string token) => [DataRow("file[0-9a-]", "file5 filea file-", "fileb file_")] [DataRow("[]a-]", "a - ]", "b [")] [DataRow("[!]a-]", "b [", "a - ]")] + [DataRow("[]-a]", "] ^ _ ` a", "- b [")] + [DataRow("[!]-a]", "- b [", "] ^ _ ` a")] [DataRow("[!-#]", "a $ ! \"", "- #")] public void GlobClassMatchesEveryMemberOfEveryRange(string pattern, string matching, string notMatching) { diff --git a/TextFilter/TextFilter.cs b/TextFilter/TextFilter.cs index 927c00c..9c320a1 100644 --- a/TextFilter/TextFilter.cs +++ b/TextFilter/TextFilter.cs @@ -575,7 +575,8 @@ private static bool SpansPathSeparator(char first, char last) => while (i < content.Length) { char first = content[i]; - bool isRange = i + 2 < content.Length && content[i + 1] == '-' && !(i == 0 && first == ']'); + // A leading "]" can start a range too: "[]-a]" is "]".."a", as in POSIX. + bool isRange = i + 2 < content.Length && content[i + 1] == '-'; if (!isRange) { members.Add(first);