Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions include/toml++/impl/parser.inl
Original file line number Diff line number Diff line change
Expand Up @@ -3157,6 +3157,11 @@ TOML_IMPL_NAMESPACE_START
if (*cp == U']')
set_error_and_return_default("tables with blank bare keys are explicitly prohibited"sv);

if (!is_bare_key_character(*cp) && !is_string_delimiter(*cp))
set_error_and_return_default("expected bare key starting character or string delimiter, saw '"sv,
to_sv(*cp),
"'"sv);

// get the actual key
start_recording();
parse_key();
Expand Down
5 changes: 5 additions & 0 deletions tests/parsing_tables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ TEST_CASE("parsing - tables")
});
parsing_should_fail(FILE_LINE_ARGS, "[]"sv);

parsing_should_fail(FILE_LINE_ARGS, "[[[1]]]"sv);
parsing_should_fail(FILE_LINE_ARGS, "[[[a]]]"sv);
parsing_should_fail(FILE_LINE_ARGS, "[[[]]"sv);
parsing_should_fail(FILE_LINE_ARGS, "[[="sv);

// "Under that, and until the next header or EOF, are the key/values of that table.
// Key/value pairs within tables are not guaranteed to be in any specific order."
parsing_should_succeed(FILE_LINE_ARGS,
Expand Down
5 changes: 5 additions & 0 deletions toml.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15741,6 +15741,11 @@ TOML_IMPL_NAMESPACE_START
if (*cp == U']')
set_error_and_return_default("tables with blank bare keys are explicitly prohibited"sv);

if (!is_bare_key_character(*cp) && !is_string_delimiter(*cp))
set_error_and_return_default("expected bare key starting character or string delimiter, saw '"sv,
to_sv(*cp),
"'"sv);

// get the actual key
start_recording();
parse_key();
Expand Down
Loading