25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-20 17:27:00 +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('24', [{:d, :COMPILER_REPORTS_ONLY_LINES}]) ++
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}])
defines = for {:d, value} <- result, do: {:d, value}
result ++ [{:d, :ALL_DEFS, defines}]

View File

@ -110,6 +110,7 @@
{if_var_true, sip, {d, 'SIP'}},
{if_var_true, stun, {d, 'STUN'}},
{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,
{if_rebar3, sql},
{if_var_true, tools, tools},

View File

@ -191,6 +191,18 @@ base_url(Server, Path) ->
_ -> Url
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, Params) ->
@ -198,17 +210,7 @@ url(Url, Params) ->
(misc:url_encode(Value))/binary>>
|| {Key, Value} <- Params],
<<$&, Encoded0/binary>> = iolist_to_binary(L),
Encoded =
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,
Encoded = uri_hack(Encoded0),
<<Url/binary, $?, Encoded/binary>>.
url(Server, Path, Params) ->
case binary:split(base_url(Server, Path), <<"?">>) of