mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-24 17:29:28 +01:00
Return userinfo from misc:uri_parse
This commit is contained in:
parent
3d4f2d365f
commit
c7ab3274c5
@ -103,7 +103,7 @@ transform(_Host, acme, ACME, Acc) ->
|
||||
ACME1 = lists:map(
|
||||
fun({ca_url, URL} = Opt) ->
|
||||
case misc:uri_parse(URL) of
|
||||
{ok, _, "acme-v01.api.letsencrypt.org", _, _, _} ->
|
||||
{ok, _, _, "acme-v01.api.letsencrypt.org", _, _, _} ->
|
||||
NewURL = ejabberd_acme:default_directory_url(),
|
||||
?WARNING_MSG("ACME directory URL ~ts defined in "
|
||||
"option acme->ca_url is deprecated "
|
||||
|
10
src/misc.erl
10
src/misc.erl
@ -62,8 +62,8 @@ uri_parse(URL) when is_binary(URL) ->
|
||||
uri_parse(binary_to_list(URL));
|
||||
uri_parse(URL) ->
|
||||
case http_uri:parse(URL) of
|
||||
{ok, {Scheme, _UserInfo, Host, Port, Path, Query}} ->
|
||||
{ok, atom_to_list(Scheme), Host, Port, Path, Query};
|
||||
{ok, {Scheme, UserInfo, Host, Port, Path, Query}} ->
|
||||
{ok, atom_to_list(Scheme), UserInfo, Host, Port, Path, Query};
|
||||
{error, _} = E ->
|
||||
E
|
||||
end.
|
||||
@ -73,11 +73,11 @@ uri_parse(URL) when is_binary(URL) ->
|
||||
uri_parse(URL) ->
|
||||
case uri_string:parse(URL) of
|
||||
#{scheme := Scheme, host := Host, port := Port, path := Path} = M1 ->
|
||||
{ok, Scheme, Host, Port, Path, maps:get(query, M1, "")};
|
||||
{ok, Scheme, maps:get(userinfo, M1, ""), Host, Port, Path, maps:get(query, M1, "")};
|
||||
#{scheme := "https", host := Host, path := Path} = M2 ->
|
||||
{ok, "https", Host, 443, Path, maps:get(query, M2, "")};
|
||||
{ok, "https", maps:get(userinfo, M2, ""), Host, 443, Path, maps:get(query, M2, "")};
|
||||
#{scheme := "http", host := Host, path := Path} = M3 ->
|
||||
{ok, "http", Host, 80, Path, maps:get(query, M3, "")};
|
||||
{ok, "http", maps:get(userinfo, M3, ""), Host, 80, Path, maps:get(query, M3, "")};
|
||||
{error, Atom, _} ->
|
||||
{error, Atom}
|
||||
end.
|
||||
|
@ -713,7 +713,7 @@ get_proc_name(ServerHost, ModuleName) ->
|
||||
-spec get_proc_name(binary(), atom(), binary()) -> atom().
|
||||
get_proc_name(ServerHost, ModuleName, PutURL) ->
|
||||
%% Once we depend on OTP >= 20.0, we can use binaries with http_uri.
|
||||
{ok, _Scheme, Host0, _Port, Path0, _Query} =
|
||||
{ok, _Scheme, _UserInfo, Host0, _Port, Path0, _Query} =
|
||||
misc:uri_parse(expand_host(PutURL, ServerHost)),
|
||||
Host = jid:nameprep(iolist_to_binary(Host0)),
|
||||
Path = str:strip(iolist_to_binary(Path0), right, $/),
|
||||
|
@ -357,7 +357,7 @@ mod_opt_type(via) ->
|
||||
(econf:and_then(
|
||||
econf:url([tls, tcp, udp]),
|
||||
fun(URI) ->
|
||||
{ok, Type, Host, Port, _, _} =
|
||||
{ok, Type, _UserInfo, Host, Port, _, _} =
|
||||
misc:uri_parse(URI),
|
||||
{list_to_atom(Type), {unicode:characters_to_binary(Host), Port}}
|
||||
end))(U)
|
||||
|
Loading…
Reference in New Issue
Block a user