25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-26 16:26:24 +01:00

Make mod_http_api assume that missing args of type list are empty list

This commit is contained in:
Paweł Chmielowski 2018-12-03 13:52:04 +01:00
parent 109ed8f2f6
commit 59a148d80b

View File

@ -325,15 +325,20 @@ handle2(Call, Auth, Args, Version) when is_atom(Call), is_list(Args) ->
format_command_result(Call, Auth, Res, Version) format_command_result(Call, Auth, Res, Version)
end. end.
get_elem_delete(A, L) -> get_elem_delete(A, L, F) ->
case proplists:get_all_values(A, L) of case proplists:get_all_values(A, L) of
[Value] -> {Value, proplists:delete(A, L)}; [Value] -> {Value, proplists:delete(A, L)};
[_, _ | _] -> [_, _ | _] ->
%% Crash reporting the error %% Crash reporting the error
exit({duplicated_attribute, A, L}); exit({duplicated_attribute, A, L});
[] -> [] ->
%% Report the error and then force a crash case F of
exit({attribute_not_found, A, L}) {list, _} ->
{[], L};
_ ->
%% Report the error and then force a crash
exit({attribute_not_found, A, L})
end
end. end.
format_args(Args, ArgsFormat) -> format_args(Args, ArgsFormat) ->
@ -342,7 +347,7 @@ format_args(Args, ArgsFormat) ->
{Args1, Res}) -> {Args1, Res}) ->
{ArgValue, Args2} = {ArgValue, Args2} =
get_elem_delete(ArgName, get_elem_delete(ArgName,
Args1), Args1, ArgFormat),
Formatted = format_arg(ArgValue, Formatted = format_arg(ArgValue,
ArgFormat), ArgFormat),
{Args2, Res ++ [Formatted]} {Args2, Res ++ [Formatted]}