fix bug where escape characters were getting dropped when operating
under `dirty_strings'
This commit is contained in:
parent
486fda2a74
commit
4f08d5355f
1 changed files with 13 additions and 5 deletions
|
@ -631,12 +631,10 @@ strip_continuations(<<Rest/binary>>, Handler, Acc, Stack, Config, _) ->
|
||||||
|
|
||||||
%% this all gets really gross and should probably eventually be folded into
|
%% this all gets really gross and should probably eventually be folded into
|
||||||
%% but for now it fakes being part of string on incompletes and errors
|
%% but for now it fakes being part of string on incompletes and errors
|
||||||
|
unescape(<<?rsolidus, Rest/binary>>, Handler, Acc, Stack, Config=#config{dirty_strings=true}) ->
|
||||||
|
string(<<?rsolidus, Rest/binary>>, Handler, acc_seq(Acc, ?rsolidus), Stack, Config);
|
||||||
unescape(<<C, Rest/binary>>, Handler, Acc, Stack, Config=#config{dirty_strings=true}) ->
|
unescape(<<C, Rest/binary>>, Handler, Acc, Stack, Config=#config{dirty_strings=true}) ->
|
||||||
case C of
|
string(Rest, Handler, acc_seq(Acc, [?rsolidus, C]), Stack, Config);
|
||||||
?doublequote -> string(Rest, Handler, acc_seq(Acc, C), Stack, Config);
|
|
||||||
?rsolidus -> string(<<?rsolidus/utf8, Rest/binary>>, Handler, acc_seq(Acc, ?rsolidus), Stack, Config);
|
|
||||||
_ -> string(Rest, Handler, acc_seq(Acc, [?rsolidus, C]), Stack, Config)
|
|
||||||
end;
|
|
||||||
unescape(<<$b, Rest/binary>>, Handler, Acc, Stack, Config) ->
|
unescape(<<$b, Rest/binary>>, Handler, Acc, Stack, Config) ->
|
||||||
string(Rest, Handler, acc_seq(Acc, maybe_replace($\b, Config)), Stack, Config);
|
string(Rest, Handler, acc_seq(Acc, maybe_replace($\b, Config)), Stack, Config);
|
||||||
unescape(<<$f, Rest/binary>>, Handler, Acc, Stack, Config) ->
|
unescape(<<$f, Rest/binary>>, Handler, Acc, Stack, Config) ->
|
||||||
|
@ -1367,6 +1365,16 @@ dirty_string_test_() ->
|
||||||
<<"[\"", 0, "\"]">>,
|
<<"[\"", 0, "\"]">>,
|
||||||
[dirty_strings]
|
[dirty_strings]
|
||||||
},
|
},
|
||||||
|
{"dirty 0\\\"0",
|
||||||
|
[start_array, {string, <<0, ?rsolidus, ?doublequote, 0>>}, end_array, end_json],
|
||||||
|
<<"[\"", 0, ?rsolidus, ?doublequote, 0, "\"]">>,
|
||||||
|
[dirty_strings]
|
||||||
|
},
|
||||||
|
{"dirty 0\\\\\"0",
|
||||||
|
[start_array, {string, <<0, ?rsolidus, ?rsolidus, ?doublequote, 0>>}, end_array, end_json],
|
||||||
|
<<"[\"", 0, ?rsolidus, ?rsolidus, ?doublequote, 0, "\"]">>,
|
||||||
|
[dirty_strings]
|
||||||
|
},
|
||||||
{"dirty 16#d800",
|
{"dirty 16#d800",
|
||||||
[start_array, {string, <<237, 160, 128>>}, end_array, end_json],
|
[start_array, {string, <<237, 160, 128>>}, end_array, end_json],
|
||||||
<<"[\"", 237, 160, 128, "\"]">>,
|
<<"[\"", 237, 160, 128, "\"]">>,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue