escape illegal js but valid json unicode characters - fixes #247
This commit is contained in:
parent
84332da399
commit
13785bddb0
@ -84,8 +84,8 @@ exports.Literal = function (node) {
|
|||||||
if (type === "string") {
|
if (type === "string") {
|
||||||
val = JSON.stringify(val);
|
val = JSON.stringify(val);
|
||||||
|
|
||||||
// escape unicode characters
|
// escape illegal js but valid json unicode characters
|
||||||
val = val.replace(/[\u007f-\uffff]/g, function (c) {
|
val = val.replace(/[\u000A\u000D\u2028\u2029]/g, function (c) {
|
||||||
return "\\u" + ("0000" + c.charCodeAt(0).toString(16)).slice(-4);
|
return "\\u" + ("0000" + c.charCodeAt(0).toString(16)).slice(-4);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user