dominictarr / JSON.sh

a pipeable JSON parser written in Bash
Other
2k stars 270 forks source link

JSON.sh cannot parse strings with the character DEL 0x7F inside #46

Open nst opened 7 years ago

nst commented 7 years ago

Step to reproduce

$ echo $'["\x7F"]' | ./JSON.sh

Expected behaviour

According to RFC 7159, character DEL 0x7F is perfectly valid unescaped.

JSON.sh should parse the string and print:

[0] "\x7F"
[]  ["\x7F"]

Actual behaviour

JSON.sh cannot parse the string and prints an error:

EXPECTED value GOT "

The issue comes from the fact that JSON.sh uses cntrl to recognize control characters in regular expressions, and cntrl includes DEL 0x7F, while JSON control characters (the one that MUST be escaped) only go from U+0000 to U+001F and don't include U+007F.

dominictarr commented 7 years ago

so we only need to change this? https://github.com/dominictarr/JSON.sh/blob/master/JSON.sh#L85-L90

do you want to make a pull request?