Skip to content

Conversation

@iphydf
Copy link
Contributor

@iphydf iphydf commented Jul 5, 2016

msgpack_object_print used fwrite to write binary data to a stream. The intention
of the function is to produce a human-readable representation of the object for
debugging purposes. Having arbitrary data dumped as is can cause issues with
terminals that interpret it as control sequences.

This change prints printable characters as is and unprintable characters as
hex-escapes ("\xNN"). Note that UTF-8 encoded characters will now be printed as
escaped sequence of UTF-8 bytes. This is an acceptable compromise, as doing
otherwise would require a light form of UTF-8 decoding and BIN-typed objects
should not be used to transport UTF-8 strings anyway (STR should be used
instead).

@redboltz
Copy link
Contributor

redboltz commented Jul 6, 2016

Hi, @iphydf. Thank you for sending the PR. I think that EXT format family's data part should use the same printing function as BIN. What do you think?
https://github.com/msgpack/msgpack/blob/master/spec.md#formats-ext

@iphydf
Copy link
Contributor Author

iphydf commented Jul 6, 2016

Agreed, changed my commit to do this.

@redboltz
Copy link
Contributor

redboltz commented Jul 7, 2016

Thank you for updating the PR. I will merge the PR to master.

msgpack_object_print used fwrite to write binary data to a stream. The intention
of the function is to produce a human-readable representation of the object for
debugging purposes. Having arbitrary data dumped as is can cause issues with
terminals that interpret it as control sequences.

This change prints printable characters as is and unprintable characters as
hex-escapes ("\xNN"). Note that UTF-8 encoded characters will now be printed as
escaped sequence of UTF-8 bytes. This is an acceptable compromise, as doing
otherwise would require a light form of UTF-8 decoding and BIN-typed objects
should not be used to transport UTF-8 strings anyway (STR should be used
instead).
@redboltz redboltz merged commit 1da0539 into msgpack:master Jul 16, 2016
@redboltz
Copy link
Contributor

merged.

iphydf referenced this pull request Jul 16, 2016
In order to print the msgpack object in a memory buffer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants