From 315a35807fe3ad8d2160b87325f84cf645ba0dcf Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Tue, 24 Sep 2024 18:46:52 +0100 Subject: [PATCH 1/3] Enable tests for invalid documents starting with n --- spec/compile_spec.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/compile_spec.lua b/spec/compile_spec.lua index 22e191b..7f4a40c 100644 --- a/spec/compile_spec.lua +++ b/spec/compile_spec.lua @@ -109,9 +109,9 @@ end local invalid_files = { "bool_trailing.json", "nil_token.json", - -- "nil_token_scalar.json", + "nil_token_scalar.json", "nully_token.json", - -- "nully_token_scalar.json" + "nully_token_scalar.json" } describe("Make sure invalid files are not accepted", function() From 3941b0f69fa25f6b2935bcdbf9fdf7b2e6e3db6e Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Tue, 24 Sep 2024 19:03:02 +0100 Subject: [PATCH 2/3] Add test for invalid document with trailing text Oddly, `null trailing` gives an error, but `nully trailing` does not --- jsonexamples/invalid/nully_trailing.json | 1 + spec/compile_spec.lua | 1 + 2 files changed, 2 insertions(+) create mode 100644 jsonexamples/invalid/nully_trailing.json diff --git a/jsonexamples/invalid/nully_trailing.json b/jsonexamples/invalid/nully_trailing.json new file mode 100644 index 0000000..ac59ceb --- /dev/null +++ b/jsonexamples/invalid/nully_trailing.json @@ -0,0 +1 @@ +nully trailing diff --git a/spec/compile_spec.lua b/spec/compile_spec.lua index 7f4a40c..4714d99 100644 --- a/spec/compile_spec.lua +++ b/spec/compile_spec.lua @@ -108,6 +108,7 @@ end local invalid_files = { "bool_trailing.json", + "nully_trailing.json", "nil_token.json", "nil_token_scalar.json", "nully_token.json", From ca36c76a60195bc55d96094d9da678f5c01a742b Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Tue, 24 Sep 2024 19:17:47 +0100 Subject: [PATCH 3/3] Add workaround for scalar document is_null bug For now, we can just manually throw the exception until the next simdjson bugfix release: https://github.com/simdjson/simdjson/pull/2258 --- src/luasimdjson.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/luasimdjson.cpp b/src/luasimdjson.cpp index fe7ddf9..5c55b57 100644 --- a/src/luasimdjson.cpp +++ b/src/luasimdjson.cpp @@ -124,6 +124,9 @@ void convert_ondemand_element_to_table(lua_State *L, T& element) { // calling is_null().value() will trigger an exception if the value is invalid if (element.is_null().value()) { lua_pushlightuserdata(L, NULL); + } else { + // workaround for simdjson 3.10.1 + throw simdjson_error(INCORRECT_TYPE); } break; }