diff --git a/src/utils/jsonToHtml.ts b/src/utils/jsonToHtml.ts
index 414c3c76a8..abd4b14afe 100644
--- a/src/utils/jsonToHtml.ts
+++ b/src/utils/jsonToHtml.ts
@@ -21,8 +21,8 @@ function htmlEncode(t) {
: '';
}
-function escapeStringQuotes(str: string) {
- return str.replace(/"/g, '\\"');
+function escapeForStringLiteral(str: string) {
+ return str.replace(/([\\"])/g, '\\$1');
}
function decorateWithSpan(value, className) {
@@ -57,11 +57,11 @@ function valueToHTML(value) {
'' +
- htmlEncode(escapeStringQuotes(value)) +
+ htmlEncode(escapeForStringLiteral(value)) +
'' +
decorateWithSpan('"', 'token string');
} else {
- output += decorateWithSpan('"' + escapeStringQuotes(value) + '"', 'token string');
+ output += decorateWithSpan('"' + escapeForStringLiteral(value) + '"', 'token string');
}
} else if (valueType === 'boolean') {
output += decorateWithSpan(value, 'token boolean');