Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Merge pull request #535 from atom/wl-bad-jsdoc
Browse files Browse the repository at this point in the history
Fix catastrophic backtracking?
  • Loading branch information
50Wliu committed Sep 21, 2017
2 parents 3d9a5fd + 6086114 commit 9c4c0e3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions grammars/jsdoc.cson
Expand Up @@ -276,11 +276,11 @@
\\s*
(
# The inner regexes are to stop the match early at */ and to not stop at escaped quotes
(?:
(?>
"(?:(?:\\*(?!/))|(?:\\\\(?!"))|[^*\\\\])*?" | # [foo="bar"] Double-quoted
'(?:(?:\\*(?!/))|(?:\\\\(?!'))|[^*\\\\])*?' | # [foo='bar'] Single-quoted
\\[ (?:(?:\\*(?!/))|[^*])*? \\] | # [foo=[1,2]] Array literal
(?:(?:\\*(?!/))|[^*])*? # Everything else
(?:(?:\\*(?!/))|\\s(?!\\s*\\])|\\[.*?(?:\\]|(?=\\*/))|[^*\\s\\[\\]])* # Everything else (sorry)
)*
)
)?
Expand Down
6 changes: 6 additions & 0 deletions spec/jsdoc-spec.coffee
Expand Up @@ -1527,3 +1527,9 @@ describe "JSDoc grammar", ->
expect(tokens[27]).toEqual value: '*/', scopes: ['source.js', 'comment.block.documentation.js', 'punctuation.definition.comment.end.js']
expect(tokens[29]).toEqual value: '20', scopes: ['source.js', 'constant.numeric.decimal.js']
expect(tokens[30]).toEqual value: ';', scopes: ['source.js', 'punctuation.terminator.statement.js']

describe "when the line ends without a closing bracket", ->
it "does not attempt to match the optional value (regression)", ->
{tokens} = grammar.tokenizeLine('/** @param {array} [bar = "x" REMOVE THE CLOSE BRACKET HERE.')
expect(tokens[9]).toEqual value: '[', scopes: ['source.js', 'comment.block.documentation.js']
expect(tokens[11]).toEqual value: ' = "x" REMOVE THE CLOSE BRACKET HERE.', scopes: ['source.js', 'comment.block.documentation.js']

0 comments on commit 9c4c0e3

Please sign in to comment.