meh / jazz

Yet another library to handle JSON in Elixir.
61 stars 21 forks source link

Emoji in string causes Jazz to choke #3

Closed jeregrine closed 10 years ago

jeregrine commented 10 years ago
iex> json = %S/{"str": "✔︎"}/
"{\"str\": \"✔︎\"}"
iex> JSON.decode!(json)
# hangs forever and immediately takes 500mb of memory then slowly falls to 100mb

Running on elixir 0.12.3 and 0.12.4-dev

meh commented 10 years ago

@devinus ^

bitwalker commented 10 years ago

I posted this in IRC:

The jazz parser looks like it expects unicode characters in \uXXXX format, if you swap out "✔︎" with "\\u2713", it works as expected.

bitwalker commented 10 years ago

Found that changing line 245 in https://github.com/meh/jazz/blob/master/lib/json/parser.ex#L244-L246 from 3 to 4 fixes the issue with this particular test case, but my guess is that whole section needs a review.

devinus commented 10 years ago

We should add a test.

meh commented 10 years ago

@devinus I added a test already in the commit.