From 5be500de1858467ff8e3b80f8aafd0e18b62eec6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Breu=C3=9F?= Date: Tue, 5 Sep 2023 09:35:59 +0200 Subject: [PATCH] refactor: add regex timeout (#49) Add a timeout of 1 second for the Regex in `Match` --- Source/Testably.Abstractions.FluentAssertions/Match.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/Testably.Abstractions.FluentAssertions/Match.cs b/Source/Testably.Abstractions.FluentAssertions/Match.cs index 9fb397a..b44284b 100644 --- a/Source/Testably.Abstractions.FluentAssertions/Match.cs +++ b/Source/Testably.Abstractions.FluentAssertions/Match.cs @@ -1,4 +1,5 @@ -using System.Text.RegularExpressions; +using System; +using System.Text.RegularExpressions; namespace Testably.Abstractions.FluentAssertions; @@ -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)); } ///