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

Is there a bug in line 156 to l65 #26

Open
fengertao opened this issue Jul 27, 2013 · 2 comments
Open

Is there a bug in line 156 to l65 #26

fengertao opened this issue Jul 27, 2013 · 2 comments

Comments

@fengertao
Copy link

The code:
case "$token" in
'{') parse_object "$jpath" ;;
'[') parse_array "$jpath" ;;
# At this point, the only valid single-character tokens are digits.
''|[!0-9]) throw "EXPECTED value GOT ${token:-EOF}" ;;
*) value=$token
isleaf=1
[ "$value" = '""' ] && isempty=1
;;
esac

I think there is one issues:
'{' should change to '^{$' ,and '[' should change to '^[$'
this is to prevent that user have a string value "abcd[efg" which will mismatch the pattern.

@dominictarr
Copy link
Owner

Okay, I just added a test for strings with json characters embedded inside it.
and the test passed, I think since the match is literal (single quotes) then it is not matched as a pattern.

https://github.com/dominictarr/JSON.sh/blob/master/test/valid/embedded.json

which is (correctly) parsed to this:
https://github.com/dominictarr/JSON.sh/blob/master/test/valid/embedded.parsed

@dominictarr
Copy link
Owner

looking at this again, you are technically correct about the behavior of this code in this context.
However, this code should have clean input, which will have already been processed by the tokenizer.

It shouldn't be possible to get an illegal character here,
unless you can find a counter example?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants