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

Matrix: Fix commit 816900a for OTP below 25.0

uri_string:quote was added in OTP 25.0
This commit is contained in:
Badlop 2024-02-16 22:02:18 +01:00
parent 045170a67e
commit 59ff77e171
3 changed files with 14 additions and 5 deletions

View File

@ -195,7 +195,8 @@
{if_var_false, sqlite, "(\"sqlite3\":_/_)"}, {if_var_false, sqlite, "(\"sqlite3\":_/_)"},
{if_var_false, zlib, "(\"ezlib\":_/_)"}]}. {if_var_false, zlib, "(\"ezlib\":_/_)"}]}.
{xref_ignores, [{eldap_filter_yecc, return_error, 2} ]}. {xref_ignores, [{eldap_filter_yecc, return_error, 2},
{http_uri, encode, 1}]}.
{eunit_compile_opts, [{i, "tools"}, {eunit_compile_opts, [{i, "tools"},
{i, "include"}]}. {i, "include"}]}.

View File

@ -41,7 +41,7 @@
intersection/2, format_val/1, cancel_timer/1, unique_timestamp/0, intersection/2, format_val/1, cancel_timer/1, unique_timestamp/0,
is_mucsub_message/1, best_match/2, pmap/2, peach/2, format_exception/4, is_mucsub_message/1, best_match/2, pmap/2, peach/2, format_exception/4,
get_my_ipv4_address/0, get_my_ipv6_address/0, parse_ip_mask/1, get_my_ipv4_address/0, get_my_ipv6_address/0, parse_ip_mask/1,
crypto_hmac/3, crypto_hmac/4, uri_parse/1, uri_parse/2, crypto_hmac/3, crypto_hmac/4, uri_parse/1, uri_parse/2, uri_quote/1,
match_ip_mask/3, format_hosts_list/1, format_cycle/1, delete_dir/1, match_ip_mask/3, format_hosts_list/1, format_cycle/1, delete_dir/1,
semver_to_xxyy/1, logical_processors/0, get_mucsub_event_type/1]). semver_to_xxyy/1, logical_processors/0, get_mucsub_event_type/1]).
@ -97,6 +97,14 @@ uri_parse(URL, Protocols) ->
end. end.
-endif. -endif.
-ifdef(OTP_BELOW_25).
uri_quote(Data) ->
http_uri:encode(Data).
-else.
uri_quote(Data) ->
uri_string:quote(Data).
-endif.
-ifdef(USE_OLD_CRYPTO_HMAC). -ifdef(USE_OLD_CRYPTO_HMAC).
crypto_hmac(Type, Key, Data) -> crypto:hmac(Type, Key, Data). crypto_hmac(Type, Key, Data) -> crypto:hmac(Type, Key, Data).
crypto_hmac(Type, Key, Data, MacL) -> crypto:hmac(Type, Key, Data, MacL). crypto_hmac(Type, Key, Data, MacL) -> crypto:hmac(Type, Key, Data, MacL).

View File

@ -743,7 +743,7 @@ sign_json(Host, JSON) ->
send_request(Host, Method, MatrixServer, Path, Query, JSON, send_request(Host, Method, MatrixServer, Path, Query, JSON,
HTTPOptions, Options) -> HTTPOptions, Options) ->
URI1 = iolist_to_binary( URI1 = iolist_to_binary(
lists:map(fun(P) -> [$/, uri_string:quote(P)] end, Path)), lists:map(fun(P) -> [$/, misc:uri_quote(P)] end, Path)),
URI = URI =
case Query of case Query of
[] -> URI1; [] -> URI1;
@ -752,8 +752,8 @@ send_request(Host, Method, MatrixServer, Path, Query, JSON,
lists:map( lists:map(
fun({K, V}) -> fun({K, V}) ->
iolist_to_binary( iolist_to_binary(
[uri_string:quote(K), $=, [misc:uri_quote(K), $=,
uri_string:quote(V)]) misc:uri_quote(V)])
end, Query), $&), end, Query), $&),
<<URI1/binary, $?, URI2/binary>> <<URI1/binary, $?, URI2/binary>>
end, end,