Skip to content

Commit

Permalink
Merge pull request #891 from Project-MONAI/FixRegex
Browse files Browse the repository at this point in the history
add timeout to regex
  • Loading branch information
neildsouth authored Oct 16, 2023
2 parents 94576ce + aa3d0b1 commit 66bddaf
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public int Parse(ReadOnlySpan<char> input, int currentIndex = 0)
{
var pattern = @"(?i:\bnull\b|''|""""|\bundefined\b)";
var replace = NULL;
input = Regex.Replace(input.ToString(), pattern, replace, RegexOptions.IgnoreCase);
input = Regex.Replace(input.ToString(), pattern, replace, RegexOptions.IgnoreCase, TimeSpan.FromSeconds(1));
}

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

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

if (currentWord.ToUpper() == CONTAINS && currentIndex != 0)
{
Expand Down

0 comments on commit 66bddaf

Please sign in to comment.