-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: prevent recursion in task regex #6639
Conversation
df12c33
to
ce49353
Compare
ce49353
to
b12877b
Compare
b12877b
to
1e4c4ea
Compare
|> range(start: -2m)` | ||
) | ||
// Fix bug with monaco error inserting an extra } here. | ||
.monacoType('{backSpace}') | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test wasn't working correctly - the monaco editor was adding an extra }
at the end, and the old regex was deleting that too - likely caught by the greedy quantifier *
. The new regex has a lazy quantifier (*?
), so it will (correctly) only match the first closing bracket from option task
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this!! 🎉
|> range(start: -2m)` | ||
) | ||
// Fix bug with monaco error inserting an extra } here. | ||
.monacoType('{backSpace}') | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
Users are hitting an error trying to save this data migration task in the Cloud2 UI. This PR fixes it by preventing a recursive loop caused by regex.
Before
Screen.Recording.2023-03-03.at.7.38.22.AM.mov
After
Screen.Recording.2023-03-03.at.7.33.29.AM.mov
Cause
The following regex on the "create task" page was intended to ensure that what the user selects for the task name and frequency in the panel on the left-hand side of the page takes precedence over any definition of the task name and frequency in the script.
script = script.replace(new RegExp('option\\s+task\\s+=\\s+{(.|\\s)*}'), '')
In other words, "Delete the part of the script that says:
option task = { whatever is in between these brackets }
".The problem is that the capturing group
(.|\s)*
causes catastrophic backtracking. It's looking for a match of any number of appearances of any whitespace character (\s
) OR any character (.
), the overlap of which results in excessive recursion. What we need is a check for "any whitespace character or any non-whitespace character until the closing bracket."The fix makes these changes:
Checklist
Authors and Reviewer(s), please verify the following: