upon further consideration, ignoring bad \uuXXXX escape sequences could be dangerous, remove test
This commit is contained in:
parent
867199539c
commit
5f6d7c1f01
3 changed files with 8 additions and 6 deletions
|
@ -594,6 +594,8 @@ escape(<<$u, Rest/binary>>, Handler, Stack, Opts) ->
|
||||||
escaped_unicode(Rest, Handler, Stack, Opts);
|
escaped_unicode(Rest, Handler, Stack, Opts);
|
||||||
escape(<<>>, Handler, Stack, Opts) ->
|
escape(<<>>, Handler, Stack, Opts) ->
|
||||||
?incomplete(escape, <<>>, Handler, Stack, Opts);
|
?incomplete(escape, <<>>, Handler, Stack, Opts);
|
||||||
|
escape(Bin, Handler, [Acc|Stack], Opts=#opts{ignore_bad_escapes=true}) ->
|
||||||
|
string(Bin, Handler, [?acc_seq(Acc, ?rsolidus)|Stack], Opts);
|
||||||
escape(Bin, Handler, Stack, Opts) ->
|
escape(Bin, Handler, Stack, Opts) ->
|
||||||
?error([Bin, Handler, Stack, Opts]).
|
?error([Bin, Handler, Stack, Opts]).
|
||||||
|
|
||||||
|
@ -1247,10 +1249,6 @@ ignore_bad_escapes_test_() ->
|
||||||
{"ignore unrecognized escape sequence", ?_assertEqual(
|
{"ignore unrecognized escape sequence", ?_assertEqual(
|
||||||
decode(<<"[\"\\x25\"]">>, [ignore_bad_escapes]),
|
decode(<<"[\"\\x25\"]">>, [ignore_bad_escapes]),
|
||||||
[start_array, {string, <<"\\x25">>}, end_array, end_json]
|
[start_array, {string, <<"\\x25">>}, end_array, end_json]
|
||||||
)},
|
|
||||||
{"ignore invalid \\uXXXX escape sequence", ?_assertEqual(
|
|
||||||
decode(<<"[\"\\uFFFF\"]">>, [ignore_bad_escapes]),
|
|
||||||
[start_array, {string, <<"\\uFFFF">>}, end_array, end_json]
|
|
||||||
)}
|
)}
|
||||||
].
|
].
|
||||||
|
|
||||||
|
|
|
@ -6,5 +6,6 @@
|
||||||
no_jsonp_escapes = false,
|
no_jsonp_escapes = false,
|
||||||
comments = false,
|
comments = false,
|
||||||
json_escape = false,
|
json_escape = false,
|
||||||
dirty_strings = false
|
dirty_strings = false,
|
||||||
|
ignore_bad_escapes = false
|
||||||
}).
|
}).
|
|
@ -53,6 +53,8 @@ parse_opts([json_escape|Rest], Opts) ->
|
||||||
parse_opts(Rest, Opts#opts{json_escape=true});
|
parse_opts(Rest, Opts#opts{json_escape=true});
|
||||||
parse_opts([dirty_strings|Rest], Opts) ->
|
parse_opts([dirty_strings|Rest], Opts) ->
|
||||||
parse_opts(Rest, Opts#opts{json_escape=true});
|
parse_opts(Rest, Opts#opts{json_escape=true});
|
||||||
|
parse_opts([ignore_bad_escapes|Rest], Opts) ->
|
||||||
|
parse_opts(Rest, Opts#opts{ignore_bad_escapes=true});
|
||||||
parse_opts(_, _) ->
|
parse_opts(_, _) ->
|
||||||
{error, badarg}.
|
{error, badarg}.
|
||||||
|
|
||||||
|
@ -66,7 +68,8 @@ valid_flags() ->
|
||||||
no_jsonp_escapes,
|
no_jsonp_escapes,
|
||||||
comments,
|
comments,
|
||||||
json_escape,
|
json_escape,
|
||||||
dirty_strings
|
dirty_strings,
|
||||||
|
ignore_bad_escapes
|
||||||
].
|
].
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue