Skip to content

Commit

Permalink
Safeguard against string unescaping loop hanging
Browse files Browse the repository at this point in the history
  • Loading branch information
josephfrazier committed May 10, 2017
1 parent 5725d48 commit 7a4cfa8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/printer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3887,8 +3887,10 @@ function makeString(rawContent, enclosingQuote) {
let minimallyEscapedContent = newContent;
let minimallyEscapedContentPrev;

let maxIterations = newContent.length;
let touched = true;
while (touched) {
while (touched && maxIterations > 0) {
maxIterations--;
touched = false;
minimallyEscapedContent = minimallyEscapedContent.replace(
regexUnnecessaryStringEscapes,
Expand Down

0 comments on commit 7a4cfa8

Please sign in to comment.