Don't send binary values to output stream

The stringification of a msgpack object shouldn't write the
raw bytes of a binary value. It will likely make the result
unprintable. Just print that it's a binary blob and include
the size. E.g.,

{"data":BIN(1032256)}

EXT is handled similarly but without the size. We now also
print the size.

Issue 994
This commit is contained in:
John Cortell
2021-11-08 08:42:31 -06:00
parent 1f663d121e
commit 9ff1b5e939

View File

@@ -466,12 +466,12 @@ struct object_stringize_visitor {
m_os << '"';
return true;
}
bool visit_bin(const char* v, uint32_t size) {
(m_os << '"').write(v, static_cast<std::streamsize>(size)) << '"';
bool visit_bin(const char* /*v*/, uint32_t size) {
m_os << "BIN(" << size << ")";
return true;
}
bool visit_ext(const char* /*v*/, uint32_t /*size*/) {
m_os << "EXT";
bool visit_ext(const char* /*v*/, uint32_t size) {
m_os << "EXT(" << size << ")";
return true;
}
bool start_array(uint32_t num_elements) {