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

Eliminate xref warning from last commit

This commit is contained in:
Paweł Chmielowski 2021-12-06 15:46:52 +01:00
parent 7897c3d0e1
commit 8d8a3177e1
3 changed files with 15 additions and 11 deletions

View File

@ -87,6 +87,7 @@ defmodule Ejabberd.MixProject do
if_version_below('23', [{:d, :USE_OLD_PG2}]) ++ if_version_below('23', [{:d, :USE_OLD_PG2}]) ++
if_version_below('24', [{:d, :COMPILER_REPORTS_ONLY_LINES}]) ++ if_version_below('24', [{:d, :COMPILER_REPORTS_ONLY_LINES}]) ++
if_version_below('24', [{:d, :SYSTOOLS_APP_DEF_WITHOUT_OPTIONAL}]) ++ if_version_below('24', [{:d, :SYSTOOLS_APP_DEF_WITHOUT_OPTIONAL}]) ++
if_function_exported(:uri_string, :normalize, 1, [{:d, :HAVE_URI_STRING}])
if_function_exported(:erl_error, :format_exception, 6, [{:d, :HAVE_ERL_ERROR}]) if_function_exported(:erl_error, :format_exception, 6, [{:d, :HAVE_ERL_ERROR}])
defines = for {:d, value} <- result, do: {:d, value} defines = for {:d, value} <- result, do: {:d, value}
result ++ [{:d, :ALL_DEFS, defines}] result ++ [{:d, :ALL_DEFS, defines}]

View File

@ -110,6 +110,7 @@
{if_var_true, sip, {d, 'SIP'}}, {if_var_true, sip, {d, 'SIP'}},
{if_var_true, stun, {d, 'STUN'}}, {if_var_true, stun, {d, 'STUN'}},
{if_have_fun, {erl_error, format_exception, 6}, {d, 'HAVE_ERL_ERROR'}}, {if_have_fun, {erl_error, format_exception, 6}, {d, 'HAVE_ERL_ERROR'}},
{if_have_fun, {uri_string, normalize, 1}, {d, 'HAVE_URI_STRING'}},
{src_dirs, [src, {src_dirs, [src,
{if_rebar3, sql}, {if_rebar3, sql},
{if_var_true, tools, tools}, {if_var_true, tools, tools},

View File

@ -191,6 +191,18 @@ base_url(Server, Path) ->
_ -> Url _ -> Url
end. end.
-ifdef(HAVE_URI_STRING).
uri_hack(Str) ->
case uri_string:normalize("%25") of
"%" -> % This hack around bug in httpc >21 <23.2
binary:replace(Str, <<"%25">>, <<"%2525">>, [global]);
_ -> Str
end.
-else.
uri_hack(Str) ->
Str.
-endif.
url(Url, []) -> url(Url, []) ->
Url; Url;
url(Url, Params) -> url(Url, Params) ->
@ -198,17 +210,7 @@ url(Url, Params) ->
(misc:url_encode(Value))/binary>> (misc:url_encode(Value))/binary>>
|| {Key, Value} <- Params], || {Key, Value} <- Params],
<<$&, Encoded0/binary>> = iolist_to_binary(L), <<$&, Encoded0/binary>> = iolist_to_binary(L),
Encoded = Encoded = uri_hack(Encoded0),
case erlang:function_exported(uri_string, normalize, 1) of
true ->
case uri_string:normalize("%25") of
"%" -> % This hack around bug in httpc >21 <23.2
binary:replace(Encoded0, <<"%25">>, <<"%2525">>, [global]);
_ -> Encoded0
end;
_ ->
Encoded0
end,
<<Url/binary, $?, Encoded/binary>>. <<Url/binary, $?, Encoded/binary>>.
url(Server, Path, Params) -> url(Server, Path, Params) ->
case binary:split(base_url(Server, Path), <<"?">>) of case binary:split(base_url(Server, Path), <<"?">>) of