Skip to content

Commit

Permalink
* Fix invalid_utf8_test test
Browse files Browse the repository at this point in the history
  • Loading branch information
lukebakken committed Aug 5, 2024
1 parent c50c6e6 commit 07e60b7
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions src/conf_parse.erl
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@ utf8_test() ->
?assertMatch(Expected, Actual),
ok.

invalid_utf8_test() ->
InvalidCodePoint = 16#11FFFF,
Expected = {error, <<"setting = thing">>, [InvalidCodePoint, $\n]},
Actual = conf_parse:parse("setting = thing" ++ [InvalidCodePoint] ++ "\n"),
?assertMatch(Expected, Actual),
ok.

invalid_included_file_test() ->
Conf = conf_parse:file("test/invalid_include_file.conf"),
?assertMatch({[], _PathWithNewLineAndCarriage, {{line,_}, {column, _}}}, Conf),
Expand Down Expand Up @@ -182,14 +189,20 @@ file(Filename) ->
end.

-spec parse(binary() | list()) -> any().
parse(List) when is_list(List) -> parse(unicode:characters_to_binary(List));
parse(List) when is_list(List) ->
case unicode:characters_to_binary(List) of
Binary when is_binary(Binary) ->
parse(Binary);
ErrorOrIncomplete ->
ErrorOrIncomplete
end;
parse(Input) when is_binary(Input) ->
_ = setup_memo(),
Result = case 'config'(Input,{{line,1},{column,1}}) of
{AST, <<>>, _Index} -> AST;
Any -> Any
end,
release_memo(), Result.
_ = setup_memo(),
Result = case 'config'(Input,{{line,1},{column,1}}) of
{AST, <<>>, _Index} -> AST;
Any -> Any
end,
release_memo(), Result.

-spec 'config'(input(), index()) -> parse_result().
'config'(Input, Index) ->
Expand Down

0 comments on commit 07e60b7

Please sign in to comment.