From 489b3fdfb5e133a87aa0173eeda66db9c5591e30 Mon Sep 17 00:00:00 2001 From: Badlop Date: Wed, 12 Nov 2025 20:48:53 +0100 Subject: [PATCH] Remove HAVE_URI_STRING --- erlang_ls.config | 1 - mix.exs | 9 --------- rebar.config | 1 - src/ext_mod.erl | 40 +++++----------------------------------- src/rest.erl | 15 +-------------- 5 files changed, 6 insertions(+), 60 deletions(-) diff --git a/erlang_ls.config b/erlang_ls.config index 62e031379..e32e1e618 100644 --- a/erlang_ls.config +++ b/erlang_ls.config @@ -11,7 +11,6 @@ include_dirs: - "_build/default/lib/*/include" - "include" macros: - - name: HAVE_URI_STRING - name: OTP_BELOW_27 - name: SIP - name: STUN diff --git a/mix.exs b/mix.exs index 53abbfc30..842564cfd 100644 --- a/mix.exs +++ b/mix.exs @@ -63,14 +63,6 @@ defmodule Ejabberd.MixProject do ] end - defp if_version_above(ver, okResult) do - if :erlang.system_info(:otp_release) > ver do - okResult - else - [] - end - end - defp if_version_below(ver, okResult) do if :erlang.system_info(:otp_release) < ver do okResult @@ -85,7 +77,6 @@ defmodule Ejabberd.MixProject do result = [{:d, :ELIXIR_ENABLED}] ++ cond_options() ++ Enum.map(includes, fn (path) -> {:i, path} end) ++ - if_version_above(~c"20", [{:d, :HAVE_URI_STRING}]) ++ if_version_below(~c"21", [{:d, :USE_OLD_HTTP_URI}]) ++ if_version_below(~c"22", [{:d, :LAGER}]) ++ if_version_below(~c"21", [{:d, :NO_CUSTOMIZE_HOSTNAME_CHECK}]) ++ diff --git a/rebar.config b/rebar.config index fa99546d8..45b7f7117 100644 --- a/rebar.config +++ b/rebar.config @@ -112,7 +112,6 @@ {erl_opts, [nowarn_deprecated_function, {i, "include"}, - {if_version_above, "20", {d, 'HAVE_URI_STRING'}}, {if_version_below, "21", {d, 'USE_OLD_HTTP_URI'}}, {if_version_below, "22", {d, 'LAGER'}}, {if_version_below, "21", {d, 'NO_CUSTOMIZE_HOSTNAME_CHECK'}}, diff --git a/src/ext_mod.erl b/src/ext_mod.erl index 7abc5eb5c..5ed9ac8bc 100644 --- a/src/ext_mod.erl +++ b/src/ext_mod.erl @@ -893,7 +893,7 @@ maybe_write_commit_json(Url, RepDir) -> end. write_commit_json(Url, RepDir) -> - Url2 = string_replace(Url, "https://github.com", "https://api.github.com/repos"), + Url2 = string:replace(Url, "https://github.com", "https://api.github.com/repos"), BranchUrl = lists:flatten(Url2 ++ "/branches/master"), case geturl(BranchUrl) of {ok, _Headers, Body} -> @@ -906,8 +906,8 @@ write_commit_json(Url, RepDir) -> find_commit_json(Attrs) -> FromPath = get_module_path(Attrs), - case {find_commit_json_path(FromPath), - find_commit_json_path(filename:join(FromPath, ".."))} + case {filelib:find_file("COMMIT.json", FromPath), + filelib:find_file("COMMIT.json", filename:join(FromPath, ".."))} of {{ok, FromFile}, _} -> FromFile; @@ -917,28 +917,6 @@ find_commit_json(Attrs) -> not_found end. --ifdef(HAVE_URI_STRING). %% Erlang/OTP 20 or higher can use this: -string_replace(Subject, Pattern, Replacement) -> - string:replace(Subject, Pattern, Replacement). - -find_commit_json_path(Path) -> - filelib:find_file("COMMIT.json", Path). --else. % Workaround for Erlang/OTP older than 20: -string_replace(Subject, Pattern, Replacement) -> - B = binary:replace(list_to_binary(Subject), - list_to_binary(Pattern), - list_to_binary(Replacement)), - binary_to_list(B). - -find_commit_json_path(Path) -> - case filelib:wildcard("COMMIT.json", Path) of - [] -> - {error, commit_json_not_found}; - ["COMMIT.json"] = File -> - {ok, filename:join(Path, File)} - end. --endif. - copy_commit_json(Package, Attrs) -> DestPath = module_lib_dir(Package), case find_commit_json(Attrs) of @@ -1186,7 +1164,7 @@ get_installed_module_el({ModAtom, Attrs}, Lang) -> Summary = list_to_binary(get_module_summary(Attrs)), Author = list_to_binary(get_module_author(Attrs)), FromPath = get_module_path(Attrs), - FromFile = case find_commit_json_path(FromPath) of + FromFile = case filelib:find_file("COMMIT.json", FromPath) of {ok, FF} -> FF; {error, _} -> "dummypath" end, @@ -1287,19 +1265,11 @@ elixir_module_name(ModAtom) -> elixir_module_name([], Res) -> lists:reverse(Res); elixir_module_name([$_, Char | Remaining], Res) -> - [Upper] = uppercase([Char]), + [Upper] = string:uppercase([Char]), elixir_module_name(Remaining, [Upper | Res]); elixir_module_name([Char | Remaining], Res) -> elixir_module_name(Remaining, [Char | Res]). --ifdef(HAVE_URI_STRING). -uppercase(String) -> - string:uppercase(String). % OTP 20 or higher --else. -uppercase(String) -> - string:to_upper(String). % OTP older than 20 --endif. - get_available_module_el({ModAtom, Attrs}) -> Installed = installed(), Mod = misc:atom_to_binary(ModAtom), diff --git a/src/rest.erl b/src/rest.erl index b2633819a..029939a80 100644 --- a/src/rest.erl +++ b/src/rest.erl @@ -210,26 +210,13 @@ 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) -> L = [<<"&", (iolist_to_binary(Key))/binary, "=", (misc:url_encode(Value))/binary>> || {Key, Value} <- Params], - <<$&, Encoded0/binary>> = iolist_to_binary(L), - Encoded = uri_hack(Encoded0), + <<$&, Encoded/binary>> = iolist_to_binary(L), <>. url(Server, Path, Params) -> case binary:split(base_url(Server, Path), <<"?">>) of