mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
C#: Fix glob pattern processing: allow **/ to match empty string
This commit is contained in:
@@ -76,8 +76,20 @@ namespace Semmle.Extraction
|
||||
throw new InvalidFilePatternException(pattern, "'**' preceeded by non-`/` character.");
|
||||
if (HasCharAt(i + 2, c => c != '/'))
|
||||
throw new InvalidFilePatternException(pattern, "'**' succeeded by non-`/` character");
|
||||
sb.Append(".*");
|
||||
i += 2;
|
||||
|
||||
if (i + 2 < pattern.Length)
|
||||
{
|
||||
// Processing .../**/...
|
||||
sb.Append("(.*/|)");
|
||||
i += 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Processing .../**
|
||||
sb.Append(".*");
|
||||
// There's no need to add another .* to the end outside the loop, we can return early.
|
||||
return sb;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user