Skip to content

Commit 9c98f22

Browse files
committed
Fixed bug #3139677: JSON [1 2 3] was incorrectly parsed as [1, 3]. Error is now correctly detected.
Modified runjsontests.py to allow test that expect failure in jsoncpp test suite.
1 parent 565a1f3 commit 9c98f22

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

NEWS.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@
6868
- Added test to ensure that the escape sequence "\/" is corrected handled
6969
by the parser.
7070

71+
* Bug fixes
72+
73+
- Bug #3139677: JSON [1 2 3] was incorrectly parsed as [1, 3]. Error is now correctly
74+
detected.
75+
7176
* License
7277

7378
- See file LICENSE for details. Basically JsonCpp is now licensed under

src/lib_json/json_reader.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,8 @@ Reader::readArray( Token &tokenStart )
533533
{
534534
ok = readToken( token );
535535
}
536-
bool badTokenType = ( token.type_ == tokenArraySeparator &&
537-
token.type_ == tokenArrayEnd );
536+
bool badTokenType = ( token.type_ != tokenArraySeparator &&
537+
token.type_ != tokenArrayEnd );
538538
if ( !ok || badTokenType )
539539
{
540540
return addErrorAndRecover( "Missing ',' or ']' in array declaration",

test/data/fail_test_array_01.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[ 1 2 3]

test/runjsontests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ def runAllTests( jsontest_executable_path, input_dir = None,
4949
failed_tests = []
5050
valgrind_path = use_valgrind and VALGRIND_CMD or ''
5151
for input_path in tests + test_jsonchecker:
52-
is_json_checker_test = input_path in test_jsonchecker
52+
expect_failure = os.path.basename( input_path ).startswith( 'fail' )
53+
is_json_checker_test = (input_path in test_jsonchecker) or expect_failure
5354
print 'TESTING:', input_path,
5455
options = is_json_checker_test and '--json-checker' or ''
5556
pipe = os.popen( "%s%s %s %s" % (
@@ -58,7 +59,6 @@ def runAllTests( jsontest_executable_path, input_dir = None,
5859
process_output = pipe.read()
5960
status = pipe.close()
6061
if is_json_checker_test:
61-
expect_failure = os.path.basename( input_path ).startswith( 'fail' )
6262
if expect_failure:
6363
if status is None:
6464
print 'FAILED'

0 commit comments

Comments
 (0)