Skip to content

Commit 73efecd

Browse files
committed
fix(javascript) final solid fix for runaway regex
1 parent 0a1e9b0 commit 73efecd

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

CHANGES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ New Languages:
1818

1919
Language Improvements:
2020

21+
- fix(r) fixed keywords not properly spaced (#2852) [Josh Goebel][]
22+
- fix(javascript) fix potential catastrophic backtracking (#2852) [Josh Goebel][]
23+
- fix(livescript) fix potential catastrophic backtracking (#2852) [Josh Goebel][]
2124
- bug(xml) XML grammar was far too imprecise/fuzzy [Josh Goebel][]
2225
- enh(xml) Improve precision to prevent false auto-detect positives [Josh Goebel][]
2326
- fix(js/ts) Prevent for/while/if/switch from falsly matching as functions (#2803) [Josh Goebel][]

src/languages/javascript.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,7 @@ export default function(hljs) {
256256
regex.lookahead(regex.concat(
257257
// we also need to allow for multiple possible comments inbetween
258258
// the first key:value pairing
259-
/(\/\/.*$)*/,
260-
/(\/\*(.|\n)*\*\/)*/,
261-
/\s*/,
259+
/(((\/\/.*$)|(\/\*(\*[^/]|[^*])*\*\/))\s*)*/,
262260
IDENT_RE + '\\s*:'))),
263261
relevance: 0,
264262
contains: [

0 commit comments

Comments
 (0)