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

handle u+a0 chars in messages #138

Open
malgorithms opened this issue Apr 25, 2019 · 1 comment
Open

handle u+a0 chars in messages #138

malgorithms opened this issue Apr 25, 2019 · 1 comment

Comments

@malgorithms
Copy link
Contributor

I somehow ended up with a string with a weird space in it.

it looked like this:

 "Please press a rune below to give your answer."

which looked pretty normal in my editor, but there was a special kind of line break character after the word rune, which I believe was the one linked below.
When the JSON gets sent to keybase chat send, the line break is messing up the JSON on the go side.

http://www.fileformat.info/info/unicode/char/00a0/index.htm

@wjblanke
Copy link

I've seen this as well, but with pretty quotes (unicode 2018 and 2019). It seems like any escaped unicode character passed to Keybase chat send causes the message to fail, eg:

(node:8370) UnhandledPromiseRejectionWarning: Error: 2019-07-02T18:24:22.160130Z ▶️ [ERRO keybase main.go:86] 001 invalid JSON: expected more JSON in input

at ChildProcess.child.on.code (/home/ubuntu/keybase-bot-master/index.js:214:16)
at ChildProcess.emit (events.js:193:13)
at maybeClose (internal/child_process.js:1001:16)
at Process.ChildProcess.handle.onexit (internal/childprocess.js:266:5)

The json for the send parameter is valid. I ran it through validators and even a golang playground which processed it OK, but it does have stuff like this:

\nSaving to: \u2018mpir-3.0.0.tar.bz2\u2019\n

Removing all \u entries lets things work. I am guessing the Keybase json parser is getting confused over the length of the message (it isn't counting the escaped unicode value correctly) and that results in the "expected more JSON in input" error since the length is shorter after being unescaped? But that is just a guess, I stopped debugging once I found the workaround.

func (c *cmdAPI) decode(ctx context.Context, r io.Reader, w io.Writer, h handler) error {
dec := json.NewDecoder(r)
for {
var c Call
if err := dec.Decode(&c); err == io.EOF {
break
} else if err != nil {
if err == io.ErrUnexpectedEOF {
return ErrInvalidJSON{message: "expected more JSON in input"}
}
return err

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

No branches or pull requests

2 participants