stricter rejection of unicode non-characters
This commit is contained in:
parent
6d0d2cfb8c
commit
4ba8c4d57e
1 changed files with 9 additions and 7 deletions
|
@ -540,14 +540,16 @@ low_surrogate(<<D/?utfx, Rest/binary>>, Stack, Opts, String, [C, B, A], High)
|
||||||
when ?is_hex(D) ->
|
when ?is_hex(D) ->
|
||||||
case erlang:list_to_integer([A, B, C, D], 16) of
|
case erlang:list_to_integer([A, B, C, D], 16) of
|
||||||
X when X >= 16#dc00, X =< 16#dfff ->
|
X when X >= 16#dc00, X =< 16#dfff ->
|
||||||
string(Rest,
|
V = surrogate_to_codepoint(High, X),
|
||||||
Stack,
|
case V rem 16#10000 of
|
||||||
Opts,
|
X when X == 16#fffe; X == 16#ffff ->
|
||||||
<<String/binary, (surrogate_to_codepoint(High, X))/utf8>>
|
{error, {badjson, <<D/?utfx, Rest/binary>>}}
|
||||||
)
|
; _ ->
|
||||||
|
string(Rest, Stack, Opts, <<String/binary, V/utf8>>)
|
||||||
|
end
|
||||||
%% not a low surrogate, bad bad bad
|
%% not a low surrogate, bad bad bad
|
||||||
; X ->
|
; _ ->
|
||||||
{error, {badjson, <<X/?utfx, Rest/binary>>}}
|
{error, {badjson, <<D/?utfx, Rest/binary>>}}
|
||||||
end;
|
end;
|
||||||
low_surrogate(<<S/?utfx, Rest/binary>>, Stack, Opts, String, Acc, High)
|
low_surrogate(<<S/?utfx, Rest/binary>>, Stack, Opts, String, Acc, High)
|
||||||
when ?is_hex(S) ->
|
when ?is_hex(S) ->
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue