mirror of
https://github.com/nlohmann/json.git
synced 2026-10-10 16:37:14 +00:00
Check strings copied from another document for valid UTF-8
An editable document only holds valid UTF-8, but copy_scalar() copied the strings and keys of a view of another document unchecked. A document of a weaker check (or a borrowed text that changed after parsing) could therefore bring ill-formed UTF-8 into it. The copy is checked now, with the error that dump() reports for the string; copies within the same document stay unchecked. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
2 files changed
+40
No files matched your search
@@ -611,6 +611,8 @@ class editor
|
||||
switch (static_cast<value_t>(n.kind))
|
||||
{
|
||||
case value_t::string:
|
||||
// (an editable document only holds valid UTF-8, whatever the check of the other document was)
|
||||
check_utf8(from.str(n), n.len);
|
||||
return string_node(from.str(n), n.len);
|
||||
case value_t::number_integer:
|
||||
case value_t::number_unsigned:
|
||||
|
||||
Reference in new issue
Block a user