Skip to content

Commit

Permalink
fix(parser) Freezing issue with illegal 0 width illegals (#2524)
Browse files Browse the repository at this point in the history
- backporting fix from v10 series
  • Loading branch information
joshgoebel committed Jul 29, 2020
1 parent dbfffac commit c7d3d99
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/highlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,16 @@ https://highlightjs.org/
mode_buffer += codeToHighlight.slice(match.index, match.index + 1);
return 1;
}

// edge case for when illegal matches $ (end of line) which is technically
// a 0 width match but not a begin/end match so it's not caught by the
// first handler (when ignoreIllegals is true)
// https://github.com/highlightjs/highlight.js/issues/2522
if (lastMatch.type==="illegal" && lexeme === "") {
mode_buffer += codeToHighlight.slice(match.index, match.index + 1);
return 1;
}

lastMatch = match;

if (match.type==="begin") {
Expand Down

0 comments on commit c7d3d99

Please sign in to comment.