From 037c3749f331c8783666d45157e857ef5e7df42c Mon Sep 17 00:00:00 2001 From: Badlop Date: Tue, 6 Sep 2022 16:46:19 +0200 Subject: [PATCH] Add support for OTP 25 (requires ejabberd newer than 17 August 2022) --- ejabberd_auth_http/src/ejabberd_auth_http.erl | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/ejabberd_auth_http/src/ejabberd_auth_http.erl b/ejabberd_auth_http/src/ejabberd_auth_http.erl index b3ab6f1..c3b1b64 100644 --- a/ejabberd_auth_http/src/ejabberd_auth_http.erl +++ b/ejabberd_auth_http/src/ejabberd_auth_http.erl @@ -180,6 +180,15 @@ remove_user_req(LUser, LServer, Password, Method) -> %%% Request maker %%%---------------------------------------------------------------------- +-ifdef(OTP_BELOW_25). +-dialyzer({no_missing_calls, [uri_quote/1]}). +uri_quote(URL) -> + http_uri:encode(URL). +-else. +uri_quote(URL) -> + uri_string:quote(URL). % Available since OTP 25.0 +-endif. + -spec make_req(post | get, binary(), binary(), binary(), binary()) -> {ok, Body :: binary()} | {error, term()}. make_req(_, _, LUser, LServer, _) when LUser == error orelse LServer == error -> @@ -195,9 +204,9 @@ make_req(Method, Path, LUser, LServer, Password) -> false -> <<"/">> end, BasicAuth64 = base64:encode(BasicAuth), - LUserE = list_to_binary(misc:uri_parse(binary_to_list(LUser))), - LServerE = list_to_binary(misc:uri_parse(binary_to_list(LServer))), - PasswordE = list_to_binary(misc:uri_parse(binary_to_list(Password))), + LUserE = list_to_binary(uri_quote(binary_to_list(LUser))), + LServerE = list_to_binary(uri_quote(binary_to_list(LServer))), + PasswordE = list_to_binary(uri_quote(binary_to_list(Password))), Query = <<"user=", LUserE/binary, "&server=", LServerE/binary, "&pass=", PasswordE/binary>>, Header = [{<<"Authorization">>, <<"Basic ", BasicAuth64/binary>>}], ContentType = {<<"Content-Type">>, <<"application/x-www-form-urlencoded">>},