mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-22 17:28:25 +01:00
mod_http_upload: Case-insensitive host comparison
Perform a case-insensitive lookup of the host name specified by the HTTP client. Fixes #2827.
This commit is contained in:
parent
3d8711f708
commit
1452023c93
@ -508,9 +508,12 @@ process(_LocalPath, #request{method = Method, host = Host, ip = IP}) ->
|
||||
-spec get_proc_name(binary(), atom()) -> atom().
|
||||
get_proc_name(ServerHost, ModuleName) ->
|
||||
PutURL = gen_mod:get_module_opt(ServerHost, ?MODULE, put_url),
|
||||
{ok, {_Scheme, _UserInfo, Host, _Port, Path, _Query}} =
|
||||
%% Once we depend on OTP >= 20.0, we can use binaries with http_uri.
|
||||
{ok, {_Scheme, _UserInfo, Host0, _Port, Path0, _Query}} =
|
||||
http_uri:parse(binary_to_list(expand_host(PutURL, ServerHost))),
|
||||
ProcPrefix = list_to_binary(string:strip(Host ++ Path, right, $/)),
|
||||
Host = jid:nameprep(iolist_to_binary(Host0)),
|
||||
Path = str:strip(iolist_to_binary(Path0), right, $/),
|
||||
ProcPrefix = <<Host/binary, Path/binary>>,
|
||||
gen_mod:get_module_proc(ProcPrefix, ModuleName).
|
||||
|
||||
-spec expand_home(binary()) -> binary().
|
||||
@ -762,7 +765,8 @@ iq_disco_info(Host, Lang, Name, AddInfo) ->
|
||||
%% HTTP request handling.
|
||||
|
||||
-spec parse_http_request(#request{}) -> {atom(), slot()}.
|
||||
parse_http_request(#request{host = Host, path = Path}) ->
|
||||
parse_http_request(#request{host = Host0, path = Path}) ->
|
||||
Host = jid:nameprep(Host0),
|
||||
PrefixLength = length(Path) - 3,
|
||||
{ProcURL, Slot} = if PrefixLength > 0 ->
|
||||
Prefix = lists:sublist(Path, PrefixLength),
|
||||
|
Loading…
Reference in New Issue
Block a user