From 9ff82fe17be0c0adfb700ea4a42ab160578c1053 Mon Sep 17 00:00:00 2001 From: Geoffrey Booth Date: Sun, 27 Aug 2017 15:16:31 -0700 Subject: [PATCH] Fix #4589: Unquote all interpolated strings, not just CSX ones, so that quotation marks are not unnecessarily escaped in backtick-delimited strings/template literals (#4660) --- lib/coffeescript/nodes.js | 2 +- src/nodes.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/coffeescript/nodes.js b/lib/coffeescript/nodes.js index d66a777d..ae461125 100644 --- a/lib/coffeescript/nodes.js +++ b/lib/coffeescript/nodes.js @@ -4989,7 +4989,7 @@ for (j = 0, len1 = elements.length; j < len1; j++) { element = elements[j]; if (element instanceof StringLiteral) { - element.value = element.unquote(this.csx); + element.value = element.unquote(true); if (!this.csx) { // Backticks and `${` inside template literals must be escaped. element.value = element.value.replace(/(\\*)(`|\$\{)/g, function(match, backslashes, toBeEscaped) { diff --git a/src/nodes.coffee b/src/nodes.coffee index 240ba923..d5ca9b1c 100644 --- a/src/nodes.coffee +++ b/src/nodes.coffee @@ -3391,7 +3391,7 @@ exports.StringWithInterpolations = class StringWithInterpolations extends Base fragments.push @makeCode '`' unless @csx for element in elements if element instanceof StringLiteral - element.value = element.unquote @csx + element.value = element.unquote yes unless @csx # Backticks and `${` inside template literals must be escaped. element.value = element.value.replace /(\\*)(`|\$\{)/g, (match, backslashes, toBeEscaped) ->