Browse Source

fix: address potential regex backtrack

dev
Evan You 7 years ago
parent
commit
cd334070f3
  1. 4
      src/compiler/codegen/events.js
  2. 4
      src/compiler/helpers.js
  3. 2
      test/unit/modules/compiler/codegen.spec.js

4
src/compiler/codegen/events.js

@ -1,7 +1,7 @@
/* @flow */
const fnExpRE = /^\s*([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/
const simplePathRE = /^\s*[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['.*?']|\[".*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*\s*$/
const fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/
const simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/
// keyCode aliases
const keyCodes: { [key: string]: number | Array<number> } = {

4
src/compiler/helpers.js

@ -100,7 +100,9 @@ export function addHandler (
events = el.events || (el.events = {})
}
const newHandler: any = { value }
const newHandler: any = {
value: value.trim()
}
if (modifiers !== emptyObject) {
newHandler.modifiers = modifiers
}

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

@ -428,7 +428,7 @@ describe('codegen', () => {
it('should not treat handler with unexpected whitespace as inline statement', () => {
assertCodegen(
'<input @input=" onInput ">',
`with(this){return _c('input',{on:{"input": onInput }})}`
`with(this){return _c('input',{on:{"input":onInput}})}`
)
})

Loading…
Cancel
Save