[ 
https://issues.apache.org/jira/browse/GROOVY-7979?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Paul King closed GROOVY-7979.
-----------------------------

> 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
(v7.6.3#76005)

Reply via email to