@@ -297,6 +297,7 @@ struct incremental_step
297297 {"d" , -1 , -1 , json_tokener_continue , 0 , 0 },
298298 {"1" , -1 , -1 , json_tokener_continue , 0 , 0 },
299299 {"e\"" , -1 , -1 , json_tokener_success , 1 , 0 },
300+
300301 /* parse two char at every time */
301302 {"\"\\u" , -1 , -1 , json_tokener_continue , 0 , 0 },
302303 {"d8" , -1 , -1 , json_tokener_continue , 0 , 0 },
@@ -322,6 +323,11 @@ struct incremental_step
322323 {"\"fff \\ud83d\\ude" , -1 , -1 , json_tokener_continue , 0 , 0 },
323324 {"00 bar\"" , -1 , -1 , json_tokener_success , 1 , 0 },
324325
326+ /* Check a utf-8 char (a+umlaut) that has bytes that look negative when
327+ char are signed (see also control char check below) */
328+ {"\"\xc3\xa4\"" , -1 , -1 , json_tokener_success , 1 , 0 },
329+ {"\"\xc3\xa4\"" , -1 , -1 , json_tokener_success , 1 , JSON_TOKENER_STRICT },
330+
325331 /* Check that json_tokener_reset actually resets */
326332 {"{ \"foo" , -1 , -1 , json_tokener_continue , 1 , 0 },
327333 {": \"bar\"}" , -1 , 0 , json_tokener_error_parse_unexpected , 1 , 0 },
@@ -394,8 +400,8 @@ struct incremental_step
394400
395401 {"Infinity" , 9 , 8 , json_tokener_success , 1 , 0 },
396402 {"infinity" , 9 , 8 , json_tokener_success , 1 , 0 },
397- {"-infinity" , 10 , 9 , json_tokener_success , 1 , 0 },
398403 {"infinity" , 9 , 0 , json_tokener_error_parse_unexpected , 1 , JSON_TOKENER_STRICT },
404+ {"-infinity" , 10 , 9 , json_tokener_success , 1 , 0 },
399405 {"-infinity" , 10 , 1 , json_tokener_error_parse_unexpected , 1 , JSON_TOKENER_STRICT },
400406
401407 {"inf" , 3 , 3 , json_tokener_continue , 0 , 0 },
@@ -462,12 +468,15 @@ struct incremental_step
462468 {"[18446744073709551616]" , 23 , 21 , json_tokener_error_parse_number , 1 , JSON_TOKENER_STRICT },
463469
464470 /* XXX this seems like a bug, should fail with _error_parse_number instead */
471+ {"18446744073709551616" , 21 , 20 , json_tokener_success , 1 , 0 },
465472 {"18446744073709551616" , 21 , 20 , json_tokener_error_parse_eof , 1 , JSON_TOKENER_STRICT },
466473
467474 /* Exceeding integer limits as double parse OK */
468475 {"[9223372036854775808.0]" , 24 , 23 , json_tokener_success , 1 , 0 },
476+ {"[-9223372036854775809.0]" , 25 , 24 , json_tokener_success , 1 , 0 },
469477 {"[-9223372036854775809.0]" , 25 , 24 , json_tokener_success , 1 , JSON_TOKENER_STRICT },
470478 {"[18446744073709551615.0]" , 25 , 24 , json_tokener_success , 1 , 0 },
479+ {"[18446744073709551616.0]" , 25 , 24 , json_tokener_success , 1 , 0 },
471480 {"[18446744073709551616.0]" , 25 , 24 , json_tokener_success , 1 , JSON_TOKENER_STRICT },
472481
473482 /* offset=1 because "n" is the start of "null". hmm... */
@@ -524,6 +533,7 @@ struct incremental_step
524533 {"\"\\a\"" , -1 , 2 , json_tokener_error_parse_string , 1 , 0 },
525534
526535 /* Check '\'' in strict model */
536+ {"\'foo\'" , -1 , 5 , json_tokener_success , 1 , 0 },
527537 {"\'foo\'" , -1 , 0 , json_tokener_error_parse_unexpected , 1 , JSON_TOKENER_STRICT },
528538
529539 /* Parse array/object */
@@ -544,9 +554,10 @@ struct incremental_step
544554 * in what we accept (up to a point).
545555 */
546556 {"[1,2,3,]" , -1 , -1 , json_tokener_success , 0 , 0 },
557+ {"[1,2,3,]" , -1 , 7 , json_tokener_error_parse_unexpected , 1 , JSON_TOKENER_STRICT },
547558 {"[1,2,,3,]" , -1 , 5 , json_tokener_error_parse_unexpected , 0 , 0 },
559+ {"[1,2,,3,]" , -1 , 5 , json_tokener_error_parse_unexpected , 0 , JSON_TOKENER_STRICT },
548560
549- {"[1,2,3,]" , -1 , 7 , json_tokener_error_parse_unexpected , 1 , JSON_TOKENER_STRICT },
550561 {"{\"a\":1,}" , -1 , 7 , json_tokener_error_parse_unexpected , 1 , JSON_TOKENER_STRICT },
551562
552563 // utf-8 test
@@ -656,7 +667,7 @@ static void test_incremental_parse(void)
656667 printf ("json_tokener_parse(%s) ... " , string_to_parse );
657668 new_obj = json_tokener_parse (string_to_parse );
658669 if (new_obj == NULL )
659- puts ( " got error as expected" );
670+ printf ( "%s" , " got error as expected\n " );
660671
661672 /* test incremental parsing in various forms */
662673 tok = json_tokener_new ();
0 commit comments