Skip to content

Null bytes in files are treated like EOF #1095

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

Activity

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

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