diff --git a/rebar.config b/rebar.config index f7779b1ef..8a520a048 100644 --- a/rebar.config +++ b/rebar.config @@ -195,7 +195,8 @@ {if_var_false, sqlite, "(\"sqlite3\":_/_)"}, {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"}, {i, "include"}]}. diff --git a/src/misc.erl b/src/misc.erl index 6d3491a90..1800ca253 100644 --- a/src/misc.erl +++ b/src/misc.erl @@ -41,7 +41,7 @@ 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, 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, semver_to_xxyy/1, logical_processors/0, get_mucsub_event_type/1]). @@ -97,6 +97,14 @@ uri_parse(URL, Protocols) -> end. -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). crypto_hmac(Type, Key, Data) -> crypto:hmac(Type, Key, Data). crypto_hmac(Type, Key, Data, MacL) -> crypto:hmac(Type, Key, Data, MacL). diff --git a/src/mod_matrix_gw.erl b/src/mod_matrix_gw.erl index 7545b0d94..3591c95ae 100644 --- a/src/mod_matrix_gw.erl +++ b/src/mod_matrix_gw.erl @@ -743,7 +743,7 @@ sign_json(Host, JSON) -> send_request(Host, Method, MatrixServer, Path, Query, JSON, HTTPOptions, Options) -> 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 = case Query of [] -> URI1; @@ -752,8 +752,8 @@ send_request(Host, Method, MatrixServer, Path, Query, JSON, lists:map( fun({K, V}) -> iolist_to_binary( - [uri_string:quote(K), $=, - uri_string:quote(V)]) + [misc:uri_quote(K), $=, + misc:uri_quote(V)]) end, Query), $&), <> end,