@@ -49,19 +49,10 @@ defmodule Poison.Parser do
49
49
50
50
@ type t :: nil | true | false | list | float | integer | String . t | map
51
51
52
- def parse! ( << 0xEF , 0xBB , 0xBF , iodata :: binary >> , options ) do
53
- parse! ( iodata , options )
54
- end
55
- def parse! ( << 0xFE , 0xFF , iodata :: binary >> , options ) do
56
- parse! ( iodata , options )
57
- end
58
- def parse! ( << 0xFF , 0xFE , iodata :: binary >> , options ) do
59
- parse! ( iodata , options )
60
- end
61
52
def parse! ( iodata , options ) do
62
53
string = IO . iodata_to_binary ( iodata )
63
54
keys = Map . get ( options , :keys )
64
- { rest , pos } = skip_whitespace ( string , 0 )
55
+ { rest , pos } = skip_whitespace ( skip_bom ( string ) , 0 )
65
56
{ value , pos , rest } = value ( rest , pos , keys )
66
57
case skip_whitespace ( rest , pos ) do
67
58
{ "" , _pos } -> value
@@ -316,6 +307,16 @@ defmodule Poison.Parser do
316
307
317
308
defp skip_whitespace ( string , pos ) , do: { string , pos }
318
309
310
+ # https://tools.ietf.org/html/rfc7159#section-8.1
311
+ # https://en.wikipedia.org/wiki/Byte_order_mark#UTF-8
312
+ defp skip_bom ( << 0xEF , 0xBB , 0xBF >> <> rest ) do
313
+ rest
314
+ end
315
+
316
+ defp skip_bom ( string ) do
317
+ string
318
+ end
319
+
319
320
## Errors
320
321
321
322
defp syntax_error ( << token :: utf8 >> <> _ , pos ) do
0 commit comments