Description
A minus sign not followed by some digits should fail parsing but succeeds. The Character Source parser correctly throws an exception..
import groovy.json.* import static groovy.json.JsonParserType.* println new JsonSlurper().setType(CHAR_BUFFER).parseText('[-]') // [-45] println new JsonSlurper().setType(INDEX_OVERLAY).parseText('[-]') // [-45] println new JsonSlurper().setType(LAX).parseText('[-]') // [-45] println new JsonSlurper().setType(CHARACTER_SOURCE).parseText('[-]') // throws JsonException
The parsers fail to recognize that no digits are appearing after the minus and end up calculating a value based on the next char value. For example, the char value of ] is 93 and that from the char value of 0 (48) is 45.
Attachments
Issue Links
- links to