Skip to content

Null bytes in files are treated like EOF #1095

@nlohmann

Description

@nlohmann
  • What is the issue you have?

When reading parsing JSON from a file, null bytes are treated as EOF. The reason for this is explicit code in the JSON lexer to treat \0 as EOF to properly parse string literals.

  • Please describe the steps to reproduce the issue. Can you provide a small but working code example?

Parse file https://github.com/nst/JSONTestSuite/blob/master/test_parsing/n_multidigit_number_then_00.json, e.g. by

std::ifstream f("n_multidigit_number_then_00.json");
json::parse(f);
  • What is the expected behavior?

Parse error: unexpected null byte after reading 123.

  • And what is the actual behavior instead?

The file is successfully parsed as number 123.

Apple LLVM version 9.1.0.

  • Did you use a released version of the library or the version from the develop branch?

develop.

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    state: stalethe issue has not been updated in a while and will be closed automatically soon unless it is updated

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions