explain some magic number nonsense
This commit is contained in:
parent
9627ceefab
commit
1c030b6eeb
1 changed files with 3 additions and 0 deletions
|
@ -562,6 +562,9 @@ partial_utf(_) -> false.
|
||||||
|
|
||||||
%% strips continuation bytes after bad utf bytes, guards against both too short
|
%% strips continuation bytes after bad utf bytes, guards against both too short
|
||||||
%% and overlong sequences. N is the maximum number of bytes to strip
|
%% and overlong sequences. N is the maximum number of bytes to strip
|
||||||
|
%% if end of input is reached before stripping the max number of continuations
|
||||||
|
%% possible magic numbers are reinserted into the stream that get us back to
|
||||||
|
%% the same state without complicated machinery
|
||||||
strip_continuations(Rest, Handler, Acc, Stack, Config, 0) ->
|
strip_continuations(Rest, Handler, Acc, Stack, Config, 0) ->
|
||||||
string(Rest, Handler, ?acc_seq(Acc, 16#fffd), Stack, Config);
|
string(Rest, Handler, ?acc_seq(Acc, 16#fffd), Stack, Config);
|
||||||
strip_continuations(<<X, Rest/binary>>, Handler, Acc, Stack, Config, N) when X >= 128, X =< 191 ->
|
strip_continuations(<<X, Rest/binary>>, Handler, Acc, Stack, Config, N) when X >= 128, X =< 191 ->
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue