-
Notifications
You must be signed in to change notification settings - Fork 783
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
add more strict checking #119
Conversation
jsmn.c
Outdated
r = jsmn_parse_string(parser, js, len, tokens, num_tokens); | ||
if (r < 0) return r; | ||
count++; | ||
if (parser->toksuper != -1 && tokens != NULL) | ||
tokens[parser->toksuper].size++; | ||
#ifdef JSMN_STRICT | ||
if (tokens != NULL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parser->toksuper
might be -1
@chlunde Fixed ! |
Any news ? |
I am using your patch in our project here: https://github.com/fluent/fluent-bit/tree/master/lib/jsmn I've found that when running in strict mode and tokens is NULL (because I want only to validate the string and not to populate results), the validation fails, a simple JSON map input like this helps to reproduce the problem:
e.g:
any hints are appreciated. |
Hi @edsiper, Thanks for highlighting this important point in my patch: The strict mode needs the array of tokens to validate a JSON: in the case of a string token, its needs to know the type of the parent to deduce the type of the next token by the function 'jsmn_string_next_tok'. For instance, if a string is being parsed and the parent is an 'array', the next type after a comma must be a 'value'. With this point in mind, I will modify the patch so that passing a NULL 'tokens' array will not be accepted by the function 'jsmn_parse'. It will look like: Warm regards, |
@lunatikub thanks for the detailed info, that makes a lot of sense, I will go ahead and deprecate the usage of jsmn_parse() in that mode. btw, have you consider to maintain a fork of this project since it low activity from a maintainer perspective ? |
JSMN in strict mode cannot be used to validate a JSON string without filing the tokens, it behavior is unexpected, more details about this in the following jsmn pull request: zserge/jsmn#119 (comment) this patch remove the flb_pack_json_valid() function. Signed-off-by: Eduardo Silva <[email protected]>
JSMN in strict mode cannot be used to validate a JSON string without filing the tokens, it behavior is unexpected, more details about this in the following jsmn pull request: zserge/jsmn#119 (comment) this patch remove the flb_pack_json_valid() function. Signed-off-by: Eduardo Silva <[email protected]>
More changes ahead. |
add more strict checking