mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2024-12-13 10:22:55 +01:00
Do not allow tokenError tokens after input if failIfExtra is set. (#1014)
Currently when failIfExtra is set and strictRoot is not set, OurReader::parse() will accept trailing non-whitespace after the JSON value as long as the first token is not a valid JSON token. This commit changes this to disallow any non-whitespace after the JSON value. This commit also suppresses the "Extra non-whitespace after JSON value." error message if parsing was aborted after another error.
This commit is contained in:
parent
abcd3f7b1f
commit
c5cb313ca0
@ -1051,12 +1051,9 @@ bool OurReader::parse(const char* beginDoc,
|
||||
nodes_.pop();
|
||||
Token token;
|
||||
skipCommentTokens(token);
|
||||
if (features_.failIfExtra_) {
|
||||
if ((features_.strictRoot_ || token.type_ != tokenError) &&
|
||||
token.type_ != tokenEndOfStream) {
|
||||
addError("Extra non-whitespace after JSON value.", token);
|
||||
return false;
|
||||
}
|
||||
if (features_.failIfExtra_ && (token.type_ != tokenEndOfStream)) {
|
||||
addError("Extra non-whitespace after JSON value.", token);
|
||||
return false;
|
||||
}
|
||||
if (collectComments_ && !commentsBefore_.empty())
|
||||
root.setComment(commentsBefore_, commentAfter);
|
||||
|
Loading…
Reference in New Issue
Block a user