Skip to content

Commit 022199e

Browse files
authored
fix: prevent recursion in task regex (#6639)
1 parent 9153cab commit 022199e

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

cypress/e2e/shared/tasks.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,18 @@ describe('Tasks - TSM', () => {
132132

133133
cy.focused()
134134

135-
cy.getByTestID('flux-editor').monacoType(`option task = {
135+
cy.getByTestID('flux-editor')
136+
.monacoType(
137+
`option task = {
136138
name: "Option Test",
137139
every: 24h,
138140
offset: 20m
139141
}
140142
from(bucket: "defbuck")
141-
|> range(start: -2m)`)
143+
|> range(start: -2m)`
144+
)
145+
// Fix bug with monaco error inserting an extra } here.
146+
.monacoType('{backSpace}')
142147

143148
cy.getByTestID('task-form-name')
144149
.click()

src/tasks/containers/TaskPage.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,9 @@ class TaskPage extends PureComponent<Props> {
145145
// if the script has a pre-defined option task = {}
146146
// we want the taskOptions to take precedence over what is provided in the script
147147
// currently we delete that part of the script
148-
script = script.replace(new RegExp('option\\s+task\\s+=\\s+{(.|\\s)*}'), '')
148+
149+
const removeTaskOptionsRegex = /option\s+task\s+=\s+{(\s|\S)*?}/
150+
script = script.replace(removeTaskOptionsRegex, '')
149151

150152
if (!isValidFlux(script)) {
151153
this.props.invalidFlux()

0 commit comments

Comments
 (0)