You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "John Wagenleitner (JIRA)" <ji...@apache.org> on 2017/05/27 21:33:04 UTC
[jira] [Resolved] (GROOVY-7979) JsonSlurper parses a single minus
character as a number
[ https://issues.apache.org/jira/browse/GROOVY-7979?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
John Wagenleitner resolved GROOVY-7979.
---------------------------------------
Resolution: Fixed
Assignee: John Wagenleitner
Fix Version/s: 2.4.12
> JsonSlurper parses a single minus character as a number
> -------------------------------------------------------
>
> Key: GROOVY-7979
> URL: https://issues.apache.org/jira/browse/GROOVY-7979
> Project: Groovy
> Issue Type: Bug
> Components: JSON
> Affects Versions: 2.4.7
> Reporter: John Wagenleitner
> Assignee: John Wagenleitner
> Priority: Minor
> Fix For: 2.4.12
>
>
> A minus sign not followed by some digits should fail parsing but succeeds. The Character Source parser correctly throws an exception..
> {code}
> 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
> {code}
> 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.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)