Skip to content

Commit cd33407

Browse files
committed
fix: address potential regex backtrack
1 parent 1fa4a5e commit cd33407

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

src/compiler/codegen/events.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* @flow */
22

3-
const fnExpRE = /^\s*([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/
4-
const simplePathRE = /^\s*[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['.*?']|\[".*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*\s*$/
3+
const fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/
4+
const simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/
55

66
// keyCode aliases
77
const keyCodes: { [key: string]: number | Array<number> } = {

src/compiler/helpers.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ export function addHandler (
100100
events = el.events || (el.events = {})
101101
}
102102

103-
const newHandler: any = { value }
103+
const newHandler: any = {
104+
value: value.trim()
105+
}
104106
if (modifiers !== emptyObject) {
105107
newHandler.modifiers = modifiers
106108
}

test/unit/modules/compiler/codegen.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ describe('codegen', () => {
428428
it('should not treat handler with unexpected whitespace as inline statement', () => {
429429
assertCodegen(
430430
'<input @input=" onInput ">',
431-
`with(this){return _c('input',{on:{"input": onInput }})}`
431+
`with(this){return _c('input',{on:{"input":onInput}})}`
432432
)
433433
})
434434

0 commit comments

Comments
 (0)