groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "John Wagenleitner (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (GROOVY-7979) JsonSlurper parses a single minus character as a number
Date Sat, 27 May 2017 21:33:04 GMT

     [ 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)

Mime
View raw message