From 0cbcea29ddc5aa17dcf46697506f9597bcbd26df Mon Sep 17 00:00:00 2001 From: Aaron Suen Date: Fri, 10 Sep 2021 08:19:20 -0400 Subject: [PATCH] More thorough escaping for JSON control chars --- luahook.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/luahook.lua b/luahook.lua index 1b7dddb..c095492 100644 --- a/luahook.lua +++ b/luahook.lua @@ -37,7 +37,9 @@ ser["number"] = function(x) end ser["boolean"] = ser["number"] ser["string"] = function(x) - return string_gsub(string_format("%q", x), "\n", "n") + return string_gsub(string_format("%q", x), "%c", function(c) + return "\\00" .. string_format("%02x", string_byte(c)) + end) end ser["table"] = function(x) local arr = {}