From fa418dcac3de13c9fe2ddc997bd53e92d793f0bc Mon Sep 17 00:00:00 2001 From: SnowOnion Date: Sun, 14 Jun 2026 21:30:49 +0800 Subject: bugfix: setting encode_escape_forward_slash on a cjson instance does not affect other instances. --- tests/test.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests/test.lua') diff --git a/tests/test.lua b/tests/test.lua index 270f63a..fc373f6 100755 --- a/tests/test.lua +++ b/tests/test.lua @@ -515,6 +515,18 @@ local cjson_tests = { { "Decode (safe) error generation after new()", function(...) return json_safe.new().decode(...) end, { "Oops" }, true, { nil, "Expected value but found invalid token at character 1" } }, + { "Set encode_escape_forward_slash on a cjson instance should not affect other instances", + function() + local j1 = json.new() + local r1 = j1.encode("/") + + local j2 = json.new() + j2.encode_escape_forward_slash(false) + local r2 = j2.encode("/") + local r3 = j1.encode("/") + return r1, r2, r3 + end, { }, + true, { [["\/"]], [["/"]], [["\/"]] } }, } print(("==> Testing Lua CJSON version %s\n"):format(json._VERSION)) -- cgit v1.2.3-55-g6feb