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

Crash when decoding some emojis #4

Closed
Alberdi opened this issue Dec 30, 2022 · 1 comment
Closed

Crash when decoding some emojis #4

Alberdi opened this issue Dec 30, 2022 · 1 comment

Comments

@Alberdi
Copy link
Member

Alberdi commented Dec 30, 2022

I'm trying to decode ❤‍🔥 (heart on fire) but njson crashes:

1> Bin = <<"{\"text\":{\"body\":\"\\u2764\\u200d\\ud83d\\udd25\"}}">>.
<<"{\"text\":{\"body\":\"\\u2764\\u200d\\ud83d\\udd25\"}}">>

2> json:decode(Bin).
[{text,[{body,<<226,157,164,226,128,141,240,159,148,165>>}]}]

3> njson:decode(Bin).
** exception error: construction of binary failed
     in function  njson_decoder:string_len/3 (/opt/chat_core/_build/default/lib/njson/src/njson_decoder.erl, line 165)
        *** segment 1 of type 'utf8': expected a non-negative integer encodable as utf8 but got: 55357
     in call from njson_decoder:string/2 (/opt/chat_core/_build/default/lib/njson/src/njson_decoder.erl, line 137)
     in call from njson:decode/1 (/opt/chat_core/_build/default/lib/njson/src/njson.erl, line 34)

The encoding of the emoji I've used above is exactly as it comes from WhatsApp.

mrrubinos added a commit that referenced this issue Jan 24, 2023
…-emojis

fix: Solves issue #4. Crash when decoding some emojis.
@javiergarea
Copy link
Member

closed by #5

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