Address review of the CBOR changes
Cite RFC 8949 Section 5.3.1 for duplicate keys, describe the out_of_range.408 condition precisely, rewrap a long line, and update the stale get_string comment (per-chunk UTF-8 check). single_include regenerated. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
5 files changed
+11
-10
No files matched your search
@@ -19,8 +19,9 @@ ignore
|
|||||||
|
|
||||||
store
|
store
|
||||||
: store tagged byte strings (for bytes 0xd8..0xdb) as binary values with the tag as subtype; other tagged values are
|
: store tagged byte strings (for bytes 0xd8..0xdb) as binary values with the tag as subtype; other tagged values are
|
||||||
read as if the tag were ignored. If several tags precede a byte string, only the tag directly in front of it is stored, and only when it has the form
|
read as if the tag were ignored. If several tags precede a byte string, only the tag directly in front of it is
|
||||||
0xd8..0xdb (a tag 0..23 written as 0xc0..0xd7 is skipped). Tags in front of a text string map key are skipped.
|
stored, and only when it has the form 0xd8..0xdb (a tag 0..23 written as 0xc0..0xd7 is skipped). Tags in front of a
|
||||||
|
text string map key are skipped.
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ Strong guarantee: if an exception is thrown, there are no changes in the JSON va
|
|||||||
string), or if a string value or object key (or one chunk of an indefinite-length string) is not valid UTF-8 and
|
string), or if a string value or object key (or one chunk of an indefinite-length string) is not valid UTF-8 and
|
||||||
`error_handler` is `strict`
|
`error_handler` is `strict`
|
||||||
- Throws [out_of_range.408](../../home/exceptions.md#jsonexceptionout_of_range408) if an array or map announces
|
- Throws [out_of_range.408](../../home/exceptions.md#jsonexceptionout_of_range408) if an array or map announces
|
||||||
more elements than `std::size_t` can hold (for example `9B FF FF FF FF FF FF FF FF`)
|
a length that `std::size_t` cannot hold, or that equals `std::size_t(-1)` (for example `9B FF FF FF FF FF FF FF FF`)
|
||||||
- Throws [out_of_range.406](../../home/exceptions.md#jsonexceptionout_of_range406) if a floating-point number does not
|
- Throws [out_of_range.406](../../home/exceptions.md#jsonexceptionout_of_range406) if a floating-point number does not
|
||||||
fit into `number_float_t`
|
fit into `number_float_t`
|
||||||
|
|
||||||
|
|||||||
@@ -248,7 +248,7 @@ string of the same major type, as required by [RFC 8949, Section 3.2.3](https://
|
|||||||
turn a key of another type into a text string.
|
turn a key of another type into a text string.
|
||||||
|
|
||||||
A map with duplicate keys is well-formed, but invalid under
|
A map with duplicate keys is well-formed, but invalid under
|
||||||
[RFC 8949, Section 5.4](https://www.rfc-editor.org/rfc/rfc8949.html#section-5.4). `from_cbor` accepts it and the
|
[RFC 8949, Section 5.3.1](https://www.rfc-editor.org/rfc/rfc8949.html#section-5.3.1). `from_cbor` accepts it and the
|
||||||
last value wins; the [SAX interface](../parsing/sax_interface.md) reports every occurrence.
|
last value wins; the [SAX interface](../parsing/sax_interface.md) reports every occurrence.
|
||||||
|
|
||||||
!!! warning "Ill-formed UTF-8 in text strings"
|
!!! warning "Ill-formed UTF-8 in text strings"
|
||||||
|
|||||||
@@ -4194,9 +4194,9 @@ class binary_reader
|
|||||||
// sequence), UBJSON, BJData, or BSON requires a decoder to reject
|
// sequence), UBJSON, BJData, or BSON requires a decoder to reject
|
||||||
// ill-formed UTF-8. Checking (and, with @ref error_handler_t::strict,
|
// ill-formed UTF-8. Checking (and, with @ref error_handler_t::strict,
|
||||||
// rejecting, or with `replace`/`ignore`, sanitizing) is opt-in via
|
// rejecting, or with `replace`/`ignore`, sanitizing) is opt-in via
|
||||||
// @ref error_handler, applied once the whole string (all chunks of
|
// @ref error_handler, applied by @ref check_string_utf8 at the call
|
||||||
// an indefinite-length CBOR string included) has been assembled, by
|
// site to the whole string or, for an indefinite-length CBOR string,
|
||||||
// @ref check_string_utf8 at the call site.
|
// to each chunk on its own (RFC 8949, Section 3.2.3).
|
||||||
return get_bytes(len, "string", result);
|
return get_bytes(len, "string", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Generated
+3
-3
@@ -21661,9 +21661,9 @@ class binary_reader
|
|||||||
// sequence), UBJSON, BJData, or BSON requires a decoder to reject
|
// sequence), UBJSON, BJData, or BSON requires a decoder to reject
|
||||||
// ill-formed UTF-8. Checking (and, with @ref error_handler_t::strict,
|
// ill-formed UTF-8. Checking (and, with @ref error_handler_t::strict,
|
||||||
// rejecting, or with `replace`/`ignore`, sanitizing) is opt-in via
|
// rejecting, or with `replace`/`ignore`, sanitizing) is opt-in via
|
||||||
// @ref error_handler, applied once the whole string (all chunks of
|
// @ref error_handler, applied by @ref check_string_utf8 at the call
|
||||||
// an indefinite-length CBOR string included) has been assembled, by
|
// site to the whole string or, for an indefinite-length CBOR string,
|
||||||
// @ref check_string_utf8 at the call site.
|
// to each chunk on its own (RFC 8949, Section 3.2.3).
|
||||||
return get_bytes(len, "string", result);
|
return get_bytes(len, "string", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user