BSON: throw json.exception.out_of_range.409 in case a key to be serialized to BSON contains a U+0000
This commit is contained in:
parent
daa3ca8a2e
commit
978c3c4116
5 changed files with 30 additions and 2 deletions
|
|
@ -681,6 +681,11 @@ class binary_writer
|
|||
*/
|
||||
static std::size_t calc_bson_entry_header_size(const typename BasicJsonType::string_t& name)
|
||||
{
|
||||
if (name.find(static_cast<CharType>(0)) != BasicJsonType::string_t::npos)
|
||||
{
|
||||
JSON_THROW(out_of_range::create(409, "BSON key cannot contain code point U+0000"));
|
||||
}
|
||||
|
||||
return /*id*/ 1ul + name.size() + /*zero-terminator*/1u;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue