Skip to content

Commit

Permalink
Fix possible regex timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveDesmond-ca committed Mar 24, 2023
1 parent 6e1cf58 commit de1b57a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ public async Task Run(Settings settings)
var labels = await _sync.GetAccountLabels(account);
_log(string.Empty);

var filteredRepos = settings.Filters.Any()
? allRepos.Where(r => settings.Filters.Any(f => new Regex(f).IsMatch(r.Name)))
var regexFilters = settings.Filters
.Select(f => new Regex(f, RegexOptions.None, TimeSpan.FromSeconds(1)))
.ToArray();

var filteredRepos = regexFilters.Any()
? allRepos.Where(r => regexFilters.Any(f => f.IsMatch(r.Name)))
: allRepos;

var repos = filteredRepos.ToArray();
Expand Down
2 changes: 1 addition & 1 deletion src/GitHubLabelSync.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>2.1.0</Version>
<Version>2.1.1</Version>
<OutputType>Exe</OutputType>
<PackAsTool>true</PackAsTool>
<ToolCommandName>sync-labels</ToolCommandName>
Expand Down

0 comments on commit de1b57a

Please sign in to comment.