summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHolger Weiss <holger@zedat.fu-berlin.de>2019-05-12 11:57:17 +0200
committerHolger Weiss <holger@zedat.fu-berlin.de>2019-05-12 11:57:17 +0200
commit1452023c937b7787418c037a67c5b6c6274d65c4 (patch)
tree2ad2fdb66ef4694dc97706e27201b3fee0887f9c
parentAvoid late arrival of get_disco_item response (diff)
mod_http_upload: Case-insensitive host comparison
Perform a case-insensitive lookup of the host name specified by the HTTP client. Fixes #2827.
-rw-r--r--src/mod_http_upload.erl10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/mod_http_upload.erl b/src/mod_http_upload.erl
index b3600e70..c1013fe7 100644
--- a/src/mod_http_upload.erl
+++ b/src/mod_http_upload.erl
@@ -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),