devinus / poison

An incredibly fast, pure Elixir JSON library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Crash with bad unicode escape sequence

michalmuskala opened this issue · comments

When the Unicode escape is 3 instead of 4 characters a crash occurs.

Poison.decode("\"\\u123\"")
** (ArgumentError) argument error
    :erlang.binary_to_integer("123\"", 16)
    (poison) lib/poison/parser.ex:250: Poison.Parser.string_escape/3
    (poison) lib/poison/parser.ex:37: Poison.Parser.parse/2
    (poison) lib/poison.ex:69: Poison.decode/2

Poison version 3.1.0
Elixir version: 1.5.0-dev (3f1e2224c)
Erlang/OTP: 20.0-rc.2

This is fixed on master:

iex(1)> Poison.decode("\"\\u123\"")
{:error, %Poison.ParseError{pos: 7, rest: nil, value: "\\u123\""}}

Oh, perfect. It's good to close, then.