Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seeing unicode in raw log for a "q tx" #5785

Closed
4 tasks
njmurarka opened this issue Mar 11, 2020 · 3 comments · Fixed by #5792
Closed
4 tasks

Seeing unicode in raw log for a "q tx" #5785

njmurarka opened this issue Mar 11, 2020 · 3 comments · Fixed by #5792

Comments

@njmurarka
Copy link
Contributor

Summary of Bug

I tried to send token ubnt to Bob, but I don't have token ubnt... only token bnt. TX raw log:

489946469bnt \u003c 1ubn" means "489946469bnt < 1ubnt

You can see unicode there showing:

\u003c

Which is the "<" sign.

Version

cosmos-sdk v0.38.1
go version go1.13.6 darwin/amd64

Steps to Reproduce

Try to send a currency denom you don't have enough of (or perhaps at all) and then look at the raw log of the result.

@alessio We discussed this yesterday, btw. Just in case you were going to file.


For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
@alessio
Copy link
Contributor

alessio commented Mar 12, 2020

This is a long standing issue and is due to how Golang JSON encoding works:

String values encode as JSON strings coerced to valid UTF-8, replacing invalid
bytes with the Unicode replacement rune. So that the JSON will be safe to
embed inside HTML <script> tags, the string is encoded using HTMLEscape,
which replaces "<", ">", "&", U+2028, and U+2029 are escaped to
"\u003c","\u003e", "\u0026", "\u2028", and "\u2029". This replacement can
be disabled when using an Encoder, by calling SetEscapeHTML(false).

(from https://golang.org/pkg/encoding/json/#Marshal)

In my very humble opinion, the simplest solution would be to replace symbols with human readable expressions that carry the same meaning, e.g. < should become smaller than, and so on.

@alessio
Copy link
Contributor

alessio commented Mar 12, 2020

Thanks @njmurarka for taking the time to report this bug and help to make the Cosmos SDK better.
A patch is provided in the aforementioned PR.

@alexanderbez
Copy link
Contributor

ACK @alessio

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants