Skip to content

Commit

Permalink
refactor: add regex timeout (#49)
Browse files Browse the repository at this point in the history
Add a timeout of 1 second for the Regex in `Match`
  • Loading branch information
vbreuss authored Sep 5, 2023
1 parent 5364317 commit 5be500d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Source/Testably.Abstractions.FluentAssertions/Match.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Text.RegularExpressions;
using System;
using System.Text.RegularExpressions;

namespace Testably.Abstractions.FluentAssertions;

Expand Down Expand Up @@ -60,7 +61,7 @@ public override bool Matches(string? value)
RegexOptions options = _ignoreCase
? RegexOptions.IgnoreCase
: RegexOptions.None;
return Regex.IsMatch(value, _pattern, options);
return Regex.IsMatch(value, _pattern, options, TimeSpan.FromMilliseconds(1000));
}

/// <inheritdoc cref="object.ToString()" />
Expand Down

0 comments on commit 5be500d

Please sign in to comment.