Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check "Parsing JSON is a Minefield" #344

Closed
nlohmann opened this issue Oct 26, 2016 · 6 comments
Closed

Check "Parsing JSON is a Minefield" #344

nlohmann opened this issue Oct 26, 2016 · 6 comments
Assignees
Milestone

Comments

@nlohmann
Copy link
Owner

http://seriot.ch/parsing_json.html describes a lot of potential issues. We should have a look whether the library is affected.

@nlohmann
Copy link
Owner Author

nlohmann commented Oct 26, 2016

Todo:

  • Add the test files from https://github.com/nst/JSONTestSuite to the test suite
  • Add test cases for the definite "yes" cases.
  • Add test cases for the definite "no" cases.
  • Investigate the "implementation-defined" cases.

@nlohmann nlohmann self-assigned this Oct 26, 2016
@nlohmann
Copy link
Owner Author

Found 6 errors when parsing the "yes" cases:

src/unit-testsuites.cpp:551: FAILED:
  CHECK_NOTHROW( j << f )
due to unexpected exception with message:
  filename := test/data/nst_json_testsuite/test_parsing/y_array_empty.json
  parse error - unexpected end of input

src/unit-testsuites.cpp:551: FAILED:
  CHECK_NOTHROW( j << f )
due to unexpected exception with message:
  filename := test/data/nst_json_testsuite/test_parsing/y_object_empty.json
  parse error - unexpected end of input

src/unit-testsuites.cpp:551: FAILED:
  CHECK_NOTHROW( j << f )
due to unexpected exception with message:
  filename := test/data/nst_json_testsuite/test_parsing/y_string_space.json
  parse error - unexpected end of input

src/unit-testsuites.cpp:551: FAILED:
  CHECK_NOTHROW( j << f )
due to unexpected exception with message:
  filename := test/data/nst_json_testsuite/test_parsing/y_string_utf16.json
  parse error - unexpected '?'

src/unit-testsuites.cpp:551: FAILED:
  CHECK_NOTHROW( j << f )
due to unexpected exception with message:
  filename := test/data/nst_json_testsuite/test_parsing/y_structure_lonely_int.json
  parse error - unexpected end of input

src/unit-testsuites.cpp:551: FAILED:
  CHECK_NOTHROW( j << f )
due to unexpected exception with message:
  filename := test/data/nst_json_testsuite/test_parsing/y_structure_string_empty.json
  parse error - unexpected end of input

nlohmann added a commit that referenced this issue Oct 29, 2016
For input files with less than 5 bytes, the parser had a bug so that
refilling the input buffer led to erasing it.
@nlohmann
Copy link
Owner Author

The UTF-16 test case (nst_json_testsuite/test_parsing/y_string_utf16.json) is the only missing failing test case. UTF-16 is not supported by this library. The README file should be adjusted accordingly.

nlohmann added a commit that referenced this issue Oct 29, 2016
@nlohmann
Copy link
Owner Author

nlohmann commented Oct 29, 2016

From the "n" test cases, there are the following errors:

Unclear/to be checked:

  • test/data/nst_json_testsuite/test_parsing/n_number_then_00.json

Overflow due to too deep nesting:

  • test/data/nst_json_testsuite/test_parsing/n_structure_100000_opening_arrays.json
  • test/data/nst_json_testsuite/test_parsing/n_structure_open_array_object.json

@nlohmann nlohmann added this to the Release 2.0.7 milestone Oct 29, 2016
nlohmann added a commit that referenced this issue Oct 29, 2016
BOMs currently yield an error.
nlohmann added a commit that referenced this issue Oct 29, 2016
nlohmann added a commit that referenced this issue Oct 30, 2016
@nlohmann
Copy link
Owner Author

nlohmann commented Nov 2, 2016

Merged fixes to develop branch. Scheduled for 2.0.7 release.

@nlohmann nlohmann closed this as completed Nov 2, 2016
@t-b
Copy link
Contributor

t-b commented Jul 18, 2019

@nlohmann I've posted a PR on the nst test suite using a more-up-to-date version, see nst/JSONTestSuite#98.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants