summaryrefslogtreecommitdiff
path: root/cli/rt/02_console.js
diff options
context:
space:
mode:
authorCasper Beyer <caspervonb@pm.me>2020-09-18 01:07:57 +0800
committerGitHub <noreply@github.com>2020-09-17 13:07:57 -0400
commita6f4559174c64066d45210b02f6a06aa2f67c2cd (patch)
treeefacdaa4035b3b5eb78d2e6b4f6144ec92b1e01d /cli/rt/02_console.js
parentc307e3e4be4e02de86103cd48d28f5ba3b18628d (diff)
fix(cli/console): escape non printable characters in object entries (#7533)
Diffstat (limited to 'cli/rt/02_console.js')
-rw-r--r--cli/rt/02_console.js6
1 files changed, 5 insertions, 1 deletions
diff --git a/cli/rt/02_console.js b/cli/rt/02_console.js
index b6f5bc74b..a5e6595b9 100644
--- a/cli/rt/02_console.js
+++ b/cli/rt/02_console.js
@@ -462,7 +462,11 @@
.replace(/\n/g, "\\n")
.replace(/\r/g, "\\r")
.replace(/\t/g, "\\t")
- .replace(/\v/g, "\\v");
+ .replace(/\v/g, "\\v")
+ .replace(
+ /[\x00-\x1f\x7f-\x9f]/g,
+ (c) => "\\x" + c.charCodeAt(0).toString(16).padStart(2, "0"),
+ );
}
// Print strings when they are inside of arrays or objects with quotes