Skip to content

Commit

Permalink
handle "[" as a malformed array index by returning NotFound
Browse files Browse the repository at this point in the history
  • Loading branch information
d-hat committed Dec 23, 2020
1 parent d15cedb commit 1e1db9e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,11 @@ func searchKeys(data []byte, keys ...string) int {
case '[':
// If we want to get array element by index
if keyLevel == level && keys[level][0] == '[' {
aIdx, err := strconv.Atoi(keys[level][1 : len(keys[level])-1])
var keyLen = len(keys[level])
if keyLen < 3 || keys[level][0] != '[' || keys[level][keyLen-1] != ']' {
return -1
}
aIdx, err := strconv.Atoi(keys[level][1 : keyLen-1])
if err != nil {
return -1
}
Expand Down

0 comments on commit 1e1db9e

Please sign in to comment.