mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-12 04:45:45 +00:00
Bug 956567 - [prettify] Pretty print in the debugger produces invalid js. r=fitzgen
This commit is contained in:
parent
5d813f2a87
commit
070ae4ffe5
@ -463,6 +463,13 @@
|
||||
return str.replace(/\n/g, "\\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure that we put "\'" into the single-quoted output instead of raw single quotes.
|
||||
*/
|
||||
function sanitizeSingleQuotes(str) {
|
||||
return str.replace(/\'/g, "\\'");
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given token to the pretty printed results.
|
||||
*
|
||||
@ -475,7 +482,7 @@
|
||||
*/
|
||||
function addToken(token, write, options) {
|
||||
if (token.type.type == "string") {
|
||||
write("'" + sanitizeNewlines(token.value) + "'",
|
||||
write("'" + sanitizeSingleQuotes(sanitizeNewlines(token.value)) + "'",
|
||||
token.startLoc.line,
|
||||
token.startLoc.column);
|
||||
} else {
|
||||
|
@ -179,7 +179,7 @@ var testCases = [
|
||||
{
|
||||
name: "String with quote",
|
||||
input: "var foo = \"'\";\n",
|
||||
output: "var foo = '\'';\n"
|
||||
output: "var foo = '\\'';\n"
|
||||
},
|
||||
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user