mirror of
https://github.com/nlohmann/json.git
synced 2026-08-06 09:13:18 +00:00
Resolve the TODO(niels) in get_ubjson_string (#5355)
The comment asked whether the no-op marker 'N' may be ignored when a string is read. It may not: at that point the next byte must be a string length type specification, and 'N' is not one. No-ops at positions where a value may start are already consumed by the callers through get_ignore_noop(), so nothing is lost by not skipping them here. Replace the TODO with a comment stating that, and add regression tests pinning both directions: a no-op is accepted at top level (also repeated), before and after an array element, and before an object key, between key and value, and before the closing brace of an object of unknown size; it is rejected where a length type specification is expected, i.e. after the 'S' marker of a string value and as the key length of an object of known size. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
@@ -12586,7 +12586,11 @@ class binary_reader
|
||||
{
|
||||
if (get_char)
|
||||
{
|
||||
get(); // TODO(niels): may we ignore N here?
|
||||
// no get_ignore_noop() here: the byte read next must be a string
|
||||
// length type specification, and a no-op ('N') is not valid in
|
||||
// that position. No-ops at positions where a value may appear are
|
||||
// already consumed by the callers via get_ignore_noop().
|
||||
get();
|
||||
}
|
||||
|
||||
if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format, "value")))
|
||||
|
||||
Reference in New Issue
Block a user