Skip to content

Commit 66bddaf

Browse files
authored
Merge pull request #891 from Project-MONAI/FixRegex
add timeout to regex
2 parents 94576ce + aa3d0b1 commit 66bddaf

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/WorkflowManager/ConditionsResolver/Resovler/Conditional.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public int Parse(ReadOnlySpan<char> input, int currentIndex = 0)
9292
{
9393
var pattern = @"(?i:\bnull\b|''|""""|\bundefined\b)";
9494
var replace = NULL;
95-
input = Regex.Replace(input.ToString(), pattern, replace, RegexOptions.IgnoreCase);
95+
input = Regex.Replace(input.ToString(), pattern, replace, RegexOptions.IgnoreCase, TimeSpan.FromSeconds(1));
9696
}
9797

9898
if (input.IsEmpty || input.IsWhiteSpace())
@@ -211,7 +211,7 @@ private int ParseChars(ReadOnlySpan<char> input, int currentIndex, char currentC
211211

212212
private int ParseExtendedOperators(ReadOnlySpan<char> input, int currentIndex)
213213
{
214-
var currentWord = Regex.Match(input.ToString(), @"\'\w+\'|^\w+").Value;
214+
var currentWord = Regex.Match(input.ToString(), @"\'\w+\'|^\w+", new RegexOptions(), TimeSpan.FromSeconds(1)).Value;
215215

216216
if (currentWord.ToUpper() == CONTAINS && currentIndex != 0)
217217
{

0 commit comments

Comments
 (0)