diff --git a/devtools/client/debugger/bin/module-manifest.json b/devtools/client/debugger/bin/module-manifest.json index 32e74415379b..4e27fbb84082 100644 --- a/devtools/client/debugger/bin/module-manifest.json +++ b/devtools/client/debugger/bin/module-manifest.json @@ -2507,7 +2507,7 @@ "byName": {}, "byBlocks": {}, "usedIds": { - "0": 0 + "1": 1 } } } @@ -2528,7 +2528,7 @@ "byName": {}, "byBlocks": {}, "usedIds": { - "0": 0 + "1": 1 } } } diff --git a/devtools/client/debugger/dist/pretty-print-worker.js b/devtools/client/debugger/dist/pretty-print-worker.js index 0acdc739883f..3bfd8530ad4c 100644 --- a/devtools/client/debugger/dist/pretty-print-worker.js +++ b/devtools/client/debugger/dist/pretty-print-worker.js @@ -6212,44 +6212,45 @@ function prependWhiteSpace(token, lastToken, addedNewline, addedSpace, write, op spaceAdded = true; } } + +const escapeCharacters = { + // Backslash + "\\": "\\\\", + // Newlines + "\n": "\\n", + // Carriage return + "\r": "\\r", + // Tab + "\t": "\\t", + // Vertical tab + "\v": "\\v", + // Form feed + "\f": "\\f", + // Null character + "\0": "\\x00", + // Line separator + "\u2028": "\\u2028", + // Paragraph separator + "\u2029": "\\u2029", + // Single quotes + "'": "\\'" +}; // eslint-disable-next-line prefer-template + +const regExpString = "(" + Object.values(escapeCharacters).join("|") + ")"; +const escapeCharactersRegExp = new RegExp(regExpString, "g"); + +function sanitizerReplaceFunc(_, c) { + return escapeCharacters[c]; +} /** * Make sure that we output the escaped character combination inside string * literals instead of various problematic characters. */ -const sanitize = function () { - const escapeCharacters = { - // Backslash - "\\": "\\\\", - // Newlines - "\n": "\\n", - // Carriage return - "\r": "\\r", - // Tab - "\t": "\\t", - // Vertical tab - "\v": "\\v", - // Form feed - "\f": "\\f", - // Null character - "\0": "\\x00", - // Line separator - "\u2028": "\\u2028", - // Paragraph separator - "\u2029": "\\u2029", - // Single quotes - "'": "\\'" - }; // eslint-disable-next-line prefer-template - - const regExpString = "(" + Object.values(escapeCharacters).join("|") + ")"; - const escapeCharactersRegExp = new RegExp(regExpString, "g"); - return function (str) { - return str.replace(escapeCharactersRegExp, function (_, c) { - return escapeCharacters[c]; - }); - }; -}(); +function sanitize(str) { + return str.replace(escapeCharactersRegExp, sanitizerReplaceFunc); +} /** * Add the given token to the pretty printed results. * diff --git a/devtools/client/debugger/src/workers/pretty-print/pretty-fast.js b/devtools/client/debugger/src/workers/pretty-print/pretty-fast.js index 36aade0209f8..6ff30c094a6a 100644 --- a/devtools/client/debugger/src/workers/pretty-print/pretty-fast.js +++ b/devtools/client/debugger/src/workers/pretty-print/pretty-fast.js @@ -537,44 +537,45 @@ function prependWhiteSpace( } } +const escapeCharacters = { + // Backslash + "\\": "\\\\", + // Newlines + "\n": "\\n", + // Carriage return + "\r": "\\r", + // Tab + "\t": "\\t", + // Vertical tab + "\v": "\\v", + // Form feed + "\f": "\\f", + // Null character + "\0": "\\x00", + // Line separator + "\u2028": "\\u2028", + // Paragraph separator + "\u2029": "\\u2029", + // Single quotes + "'": "\\'", +}; + +// eslint-disable-next-line prefer-template +const regExpString = "(" + Object.values(escapeCharacters).join("|") + ")"; +const escapeCharactersRegExp = new RegExp(regExpString, "g"); + +function sanitizerReplaceFunc(_, c) { + return escapeCharacters[c]; +} + /** * Make sure that we output the escaped character combination inside string * literals instead of various problematic characters. */ -const sanitize = (function() { - const escapeCharacters = { - // Backslash - "\\": "\\\\", - // Newlines - "\n": "\\n", - // Carriage return - "\r": "\\r", - // Tab - "\t": "\\t", - // Vertical tab - "\v": "\\v", - // Form feed - "\f": "\\f", - // Null character - "\0": "\\x00", - // Line separator - "\u2028": "\\u2028", - // Paragraph separator - "\u2029": "\\u2029", - // Single quotes - "'": "\\'", - }; +function sanitize(str) { + return str.replace(escapeCharactersRegExp, sanitizerReplaceFunc); +} - // eslint-disable-next-line prefer-template - const regExpString = "(" + Object.values(escapeCharacters).join("|") + ")"; - const escapeCharactersRegExp = new RegExp(regExpString, "g"); - - return function(str) { - return str.replace(escapeCharactersRegExp, function(_, c) { - return escapeCharacters[c]; - }); - }; -})(); /** * Add the given token to the pretty printed results. *