Skip to content

Commit 5be500d

Browse files
authored
refactor: add regex timeout (#49)
Add a timeout of 1 second for the Regex in `Match`
1 parent 5364317 commit 5be500d

File tree

1 file changed

+3
-2
lines changed
  • Source/Testably.Abstractions.FluentAssertions

1 file changed

+3
-2
lines changed

Source/Testably.Abstractions.FluentAssertions/Match.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Text.RegularExpressions;
1+
using System;
2+
using System.Text.RegularExpressions;
23

34
namespace Testably.Abstractions.FluentAssertions;
45

@@ -60,7 +61,7 @@ public override bool Matches(string? value)
6061
RegexOptions options = _ignoreCase
6162
? RegexOptions.IgnoreCase
6263
: RegexOptions.None;
63-
return Regex.IsMatch(value, _pattern, options);
64+
return Regex.IsMatch(value, _pattern, options, TimeSpan.FromMilliseconds(1000));
6465
}
6566

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

0 commit comments

Comments
 (0)