Skip to content

Commit

Permalink
fix: address potential regex backtrack
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Feb 21, 2018
1 parent 1fa4a5e commit cd33407
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/compiler/codegen/events.js
Original file line number Diff line number Diff line change
@@ -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> } = {
Expand Down
4 changes: 3 additions & 1 deletion src/compiler/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion test/unit/modules/compiler/codegen.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}})}`
)
})

Expand Down

0 comments on commit cd33407

Please sign in to comment.