Skip to content

Commit

Permalink
fix: prevent recursion in task regex (#6639)
Browse files Browse the repository at this point in the history
  • Loading branch information
wdoconnell authored Mar 3, 2023
1 parent 9153cab commit 022199e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 7 additions & 2 deletions cypress/e2e/shared/tasks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,18 @@ describe('Tasks - TSM', () => {

cy.focused()

cy.getByTestID('flux-editor').monacoType(`option task = {
cy.getByTestID('flux-editor')
.monacoType(
`option task = {
name: "Option Test",
every: 24h,
offset: 20m
}
from(bucket: "defbuck")
|> range(start: -2m)`)
|> range(start: -2m)`
)
// Fix bug with monaco error inserting an extra } here.
.monacoType('{backSpace}')

cy.getByTestID('task-form-name')
.click()
Expand Down
4 changes: 3 additions & 1 deletion src/tasks/containers/TaskPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ class TaskPage extends PureComponent<Props> {
// if the script has a pre-defined option task = {}
// we want the taskOptions to take precedence over what is provided in the script
// currently we delete that part of the script
script = script.replace(new RegExp('option\\s+task\\s+=\\s+{(.|\\s)*}'), '')

const removeTaskOptionsRegex = /option\s+task\s+=\s+{(\s|\S)*?}/
script = script.replace(removeTaskOptionsRegex, '')

if (!isValidFlux(script)) {
this.props.invalidFlux()
Expand Down

0 comments on commit 022199e

Please sign in to comment.