From 64280be17fb86e036631f3aeb5ae97e7313da7e3 Mon Sep 17 00:00:00 2001 From: Josh Goebel Date: Thu, 12 Nov 2020 07:43:29 -0500 Subject: [PATCH] fix(javascript) final solid fix for runaway regex --- CHANGES.md | 3 +++ src/languages/javascript.js | 4 +--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 5363f68b3d..e6e1f1f4a9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -22,6 +22,9 @@ New Languages: Language Improvements: +- fix(r) fixed keywords not properly spaced (#2852) [Josh Goebel][] +- fix(javascript) fix potential catastrophic backtracking (#2852) [Josh Goebel][] +- fix(livescript) fix potential catastrophic backtracking (#2852) [Josh Goebel][] - bug(xml) XML grammar was far too imprecise/fuzzy [Josh Goebel][] - enh(xml) Improve precision to prevent false auto-detect positives [Josh Goebel][] - fix(js/ts) Prevent for/while/if/switch from falsly matching as functions (#2803) [Josh Goebel][] diff --git a/src/languages/javascript.js b/src/languages/javascript.js index 918a01c54a..2bccc2190c 100644 --- a/src/languages/javascript.js +++ b/src/languages/javascript.js @@ -256,9 +256,7 @@ export default function(hljs) { regex.lookahead(regex.concat( // we also need to allow for multiple possible comments inbetween // the first key:value pairing - /(\/\/.*$)*/, - /(\/\*(.|\n)*\*\/)*/, - /\s*/, + /(((\/\/.*$)|(\/\*(\*[^/]|[^*])*\*\/))\s*)*/, IDENT_RE + '\\s*:'))), relevance: 0, contains: [