Menu

#50 Additional closing curly brace is missed by parser

0.5.0
closed-invalid
nobody
Reader (16)
5
2015-03-06
2012-09-12
k-cid
No

An additional closing curly brace is missed by the parser. If a file contains a closing curly brace too many, parsing is ended prematurely.
Multiple things could happen in case of an additional closing curly brace:
- The amount of curly braces in the document can be counted and the opening ones should match the closing ones
- The amount of bytes read could be returned for verification (compare with file size)
- A warning/error can be given if there are characters found after the curly brace

The current silent ending of the read process gives unintended behaviour.

Example Json:
{
"Product A":
{
"address": [ 84 ],
"filename": "filea.bx",
"version": "v01.04.F1.dev",
"enabled": true,
"hasCan": true,
"boardaddresses" : [ 1 , 2 ]
}
},
"Product B":
{
"address": [ 85 ],
"filename": "fileb.bx",
"version": "01.02.06",
"enabled": false,
"hasCan": true
}
}

Discussion

  • Marcel Parnas

    Marcel Parnas - 2014-03-03

    Basically anything that can parse as a valid token will be accepted (and ignored) at the end of an otherwise valid string. Our solution was to add the following code to the main parse routine, just before check for features_.strictRoot_ :

    if ( current_ != end_ )
    {
    token.type_ = tokenError;
    token.start_ = current_;
    token.end_ = endDoc;
    addError( "Root node successfully parsed but extra data was found and not parsed.",
    token );
    return false;
    }

     
  • Christopher Dunn

    That's not a bug, but it's prevented by using strictMode at: https://github.com/open-source-parsers/jsoncpp/

     
  • Christopher Dunn

    • status: open --> closed-invalid
    • Group: --> 0.5.0
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.