fix: escape quotes in string values

fixes #882
This commit is contained in:
Roman Hotsiy 2019-02-26 10:02:41 +02:00
parent 3659a75020
commit 04731656db
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0

View File

@ -21,6 +21,10 @@ function htmlEncode(t) {
: '';
}
function escapeStringQuotes(str: string) {
return str.replace(/"/g, '\\"');
}
function decorateWithSpan(value, className) {
return '<span class="' + className + '">' + htmlEncode(value) + '</span>';
}
@ -53,11 +57,11 @@ function valueToHTML(value) {
'<a href="' +
value +
'">' +
htmlEncode(value) +
htmlEncode(escapeStringQuotes(value)) +
'</a>' +
decorateWithSpan('"', 'token string');
} else {
output += decorateWithSpan('"' + value + '"', 'token string');
output += decorateWithSpan('"' + escapeStringQuotes(value) + '"', 'token string');
}
} else if (valueType === 'boolean') {
output += decorateWithSpan(value, 'token boolean');