Skip to content

Commit

Permalink
Enable tests for invalid documents starting with n (#94)
Browse files Browse the repository at this point in the history
* Enable tests for invalid documents starting with n

* Add test for invalid document with trailing text

Oddly, `null trailing` gives an error, but `nully trailing` does not

* Add workaround for scalar document is_null bug

For now, we can just manually throw the exception until the next
simdjson bugfix release: simdjson/simdjson#2258
  • Loading branch information
tobil4sk authored Sep 26, 2024
1 parent 4a65dc5 commit d2dd6a3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions jsonexamples/invalid/nully_trailing.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nully trailing
5 changes: 3 additions & 2 deletions spec/compile_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,11 @@ end

local invalid_files = {
"bool_trailing.json",
"nully_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()
Expand Down
3 changes: 3 additions & 0 deletions src/luasimdjson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit d2dd6a3

Please sign in to comment.