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

Decoding invalid utf-8 gives Internal server error #83

Open
Cody119 opened this issue Mar 11, 2022 · 2 comments
Open

Decoding invalid utf-8 gives Internal server error #83

Cody119 opened this issue Mar 11, 2022 · 2 comments

Comments

@Cody119
Copy link

Cody119 commented Mar 11, 2022

Trying to decoding the following byte sequences returns a internal server error.
82 04 68 4b 43 01 20 03 ac 02 08

I think its because it encodes an invalid utf-8 string. Im pretty sure this sequence represents [4, "KC<0x01> <0x03>"] (where <0x01> and <0x03> are ASCII SOH and ETX).

You don't need any special settings enabled, just load up cbor.me, copy the sequence into the right hand

@chrysn
Copy link

chrysn commented Mar 11, 2022

I can't move the issue around, but it belongs to cbor-diag. I've copied it over to cabo/cbor-diag#21 where it is tracked better.

@cabo
Copy link
Contributor

cabo commented Mar 11, 2022

The fix for erroring out so unceremoniously can be discussed over there, but I note that there is a bare 0xac in the input, which indeed is not valid UTF-8 unless following certain other bytes. See below what happens when I fix this to 0x4c ("L").

$ echo 82 04 68 4b 43 01 20 03 ac 02 08 | pretty2diag.rb
/Volumes/nar/Users/cabo-rescue/lib/ruby/gems/3.1.0/gems/cbor-diag-0.7.6/lib/cbor-diagnostic.rb:73:in `to_json': source sequence is illegal/malformed utf-8 (JSON::GeneratorError)
$ echo 82 04 68 4b 43 01 20 03 4c 02 08 | pretty2diag.rb
[4, "KC\u0001 \u0003L\u0002\b"]

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

3 participants