-
Notifications
You must be signed in to change notification settings - Fork 982
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
Integer parsing allows illegal spaces or structural indices. #1878
Comments
I will review! |
It is acceptable for 123] to produce 123 and then an error, or to just produce an error, but unacceptable to produce 123 6 times! |
We are potentially missing a check when it is a lone number. |
Sorry for any confusion. 6 times actually mean one time in each loop iteration. They are different strings. |
So what happens is that we consume the number, but even though we advance, we never read the trailing component that follows so we never create an error. The solution is to simply add an additional check when the parsing is a success, we must also verify that there is nothing else in the document. It is a small thing... |
Describe the bug
Integer parsing (
get_int64
,get_uint64
) may allow illegal JSON strings containing an integer followed by illegal spaces or structural indices.To Reproduce
With the loop, the parsed JSON string will be
"123[abc"
,"123]abc"
, ... None of them is a valid JSON string. However,get_int64
will return123
regardless of the error. Only when the string is set to"123-abc"
, where-
is not a space or structural index, can the error be correctly reported.The expected behavior of the code is throwing an exception at the first
doc.get_int64().value()
in the loop. The actual behavior is outputting123
six times in the loop, and only throwing an exception at the lastdoc.get_int64().value()
outside the loop.simjson release
v1.1.0 (commit 8c1bfe7).
Configuration (please complete the following information if relevant)
The text was updated successfully, but these errors were encountered: