diff --git a/src/printer.js b/src/printer.js
index 93a30773..4d0b22b1 100644
--- a/src/printer.js
+++ b/src/printer.js
@@ -1200,7 +1200,10 @@ function genericPrintNoParens(path, options, print) {
(n.value.type === "StringLiteral" || n.value.type === "Literal") &&
typeof n.value.value === "string"
) {
- res = '"' + util.htmlEscapeInsideDoubleQuote(n.value.value) + '"';
+ const value = n.value.extra ? n.value.extra.raw : n.value.raw;
+ res = '"' +
+ value.slice(1, value.length - 1).replace(/"/g, """) +
+ '"';
} else {
res = path.call(print, "value");
}
diff --git a/src/util.js b/src/util.js
index ecf786f1..0b5f6a1b 100644
--- a/src/util.js
+++ b/src/util.js
@@ -265,16 +265,6 @@ function setLocEnd(node, index) {
}
}
-// http://stackoverflow.com/a/7124052
-function htmlEscapeInsideDoubleQuote(str) {
- return str.replace(/&/g, "&").replace(/"/g, """);
- // Intentionally disable the following since it is safe inside of a
- // double quote context
- // .replace(/'/g, ''')
- // .replace(//g, '>');
-}
-
// http://stackoverflow.com/a/7124052
function htmlEscapeInsideAngleBracket(str) {
return str.replace(//g, ">");
@@ -328,6 +318,5 @@ module.exports = {
locEnd,
setLocStart,
setLocEnd,
- htmlEscapeInsideDoubleQuote,
htmlEscapeInsideAngleBracket
};
diff --git a/tests/jsx/__snapshots__/jsfmt.spec.js.snap b/tests/jsx/__snapshots__/jsfmt.spec.js.snap
index 31784417..defb942d 100644
--- a/tests/jsx/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/jsx/__snapshots__/jsfmt.spec.js.snap
@@ -139,6 +139,17 @@ exports[`expression.js 1`] = `
"
`;
+exports[`html_escape.js 1`] = `
+"export default () => ;
+
+() => ;
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+export default () => ;
+
+() =>
;
+"
+`;
+
exports[`hug.js 1`] = `
"