Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reject invalid non-null tokens beginning with n #93

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions jsonexamples/invalid/nil_token.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[nil]
1 change: 1 addition & 0 deletions jsonexamples/invalid/nil_token_scalar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nil
1 change: 1 addition & 0 deletions jsonexamples/invalid/nully_token.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[nully]
1 change: 1 addition & 0 deletions jsonexamples/invalid/nully_token_scalar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nully
6 changes: 5 additions & 1 deletion spec/compile_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@ if tonumber(major) >= 5 and tonumber(minor) >= 3 then
end

local invalid_files = {
"bool_trailing.json"
"bool_trailing.json",
"nil_token.json",
-- "nil_token_scalar.json",
"nully_token.json",
-- "nully_token_scalar.json"
}

describe("Make sure invalid files are not accepted", function()
Expand Down
5 changes: 4 additions & 1 deletion src/luasimdjson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@ void convert_ondemand_element_to_table(lua_State *L, T& element) {
break;

case ondemand::json_type::null:
lua_pushlightuserdata(L, NULL);
// calling is_null().value() will trigger an exception if the value is invalid
if (element.is_null().value()) {
lua_pushlightuserdata(L, NULL);
}
break;
}
}
Expand Down