mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
Make webadmin redirect to page that end with /
This commit is contained in:
parent
73ba38ae35
commit
5ec214386e
@ -21,6 +21,7 @@
|
|||||||
-record(request,
|
-record(request,
|
||||||
{method :: method(),
|
{method :: method(),
|
||||||
path = [] :: [binary()],
|
path = [] :: [binary()],
|
||||||
|
raw_path :: binary(),
|
||||||
q = [] :: [{binary() | nokey, binary()}],
|
q = [] :: [{binary() | nokey, binary()}],
|
||||||
us = {<<>>, <<>>} :: {binary(), binary()},
|
us = {<<>>, <<>>} :: {binary(), binary()},
|
||||||
auth :: {binary(), binary()} | {oauth, binary(), []} | undefined | invalid,
|
auth :: {binary(), binary()} | {oauth, binary(), []} | undefined | invalid,
|
||||||
|
@ -386,7 +386,7 @@ extract_path_query(#state{request_method = Method,
|
|||||||
{'EXIT', _Reason} -> [];
|
{'EXIT', _Reason} -> [];
|
||||||
LQ -> LQ
|
LQ -> LQ
|
||||||
end,
|
end,
|
||||||
{State, {LPath, LQuery, <<"">>}}
|
{State, {LPath, LQuery, <<"">>, Path}}
|
||||||
end;
|
end;
|
||||||
extract_path_query(#state{request_method = Method,
|
extract_path_query(#state{request_method = Method,
|
||||||
request_path = {abs_path, Path},
|
request_path = {abs_path, Path},
|
||||||
@ -402,7 +402,7 @@ extract_path_query(#state{request_method = Method,
|
|||||||
{LPath, _Query} ->
|
{LPath, _Query} ->
|
||||||
case Method of
|
case Method of
|
||||||
'PUT' ->
|
'PUT' ->
|
||||||
{State, {LPath, [], Trail}};
|
{State, {LPath, [], Trail, Path}};
|
||||||
'POST' ->
|
'POST' ->
|
||||||
case recv_data(State) of
|
case recv_data(State) of
|
||||||
{ok, Data} ->
|
{ok, Data} ->
|
||||||
@ -410,7 +410,7 @@ extract_path_query(#state{request_method = Method,
|
|||||||
{'EXIT', _Reason} -> [];
|
{'EXIT', _Reason} -> [];
|
||||||
LQ -> LQ
|
LQ -> LQ
|
||||||
end,
|
end,
|
||||||
{State, {LPath, LQuery, Data}};
|
{State, {LPath, LQuery, Data, Path}};
|
||||||
error ->
|
error ->
|
||||||
{State, false}
|
{State, false}
|
||||||
end
|
end
|
||||||
@ -451,7 +451,7 @@ process_request(#state{request_method = Method,
|
|||||||
case extract_path_query(State) of
|
case extract_path_query(State) of
|
||||||
{State2, false} ->
|
{State2, false} ->
|
||||||
{State2, make_bad_request(State)};
|
{State2, make_bad_request(State)};
|
||||||
{State2, {LPath, LQuery, Data}} ->
|
{State2, {LPath, LQuery, Data, RawPath}} ->
|
||||||
PeerName = case SockPeer of
|
PeerName = case SockPeer of
|
||||||
none ->
|
none ->
|
||||||
case SockMod of
|
case SockMod of
|
||||||
@ -471,6 +471,7 @@ process_request(#state{request_method = Method,
|
|||||||
IP = analyze_ip_xff(IPHere, XFF),
|
IP = analyze_ip_xff(IPHere, XFF),
|
||||||
Request = #request{method = Method,
|
Request = #request{method = Method,
|
||||||
path = LPath,
|
path = LPath,
|
||||||
|
raw_path = RawPath,
|
||||||
q = LQuery,
|
q = LQuery,
|
||||||
auth = Auth,
|
auth = Auth,
|
||||||
length = Length,
|
length = Length,
|
||||||
|
@ -150,7 +150,21 @@ url_to_path(URL) -> str:tokens(URL, <<"/">>).
|
|||||||
%%%==================================
|
%%%==================================
|
||||||
%%%% process/2
|
%%%% process/2
|
||||||
|
|
||||||
process([<<"server">>, SHost | RPath] = Path,
|
process(Path, #request{raw_path = RawPath} = Request) ->
|
||||||
|
Continue = case Path of
|
||||||
|
[E] ->
|
||||||
|
binary:match(E, <<".">>) /= nomatch;
|
||||||
|
_ ->
|
||||||
|
false
|
||||||
|
end,
|
||||||
|
case Continue orelse binary:at(RawPath, size(RawPath) - 1) == $/ of
|
||||||
|
true ->
|
||||||
|
process2(Path, Request);
|
||||||
|
_ ->
|
||||||
|
{301, [{<<"Location">>, <<RawPath/binary, "/">>}], <<>>}
|
||||||
|
end.
|
||||||
|
|
||||||
|
process2([<<"server">>, SHost | RPath] = Path,
|
||||||
#request{auth = Auth, lang = Lang, host = HostHTTP,
|
#request{auth = Auth, lang = Lang, host = HostHTTP,
|
||||||
method = Method} =
|
method = Method} =
|
||||||
Request) ->
|
Request) ->
|
||||||
@ -185,7 +199,7 @@ process([<<"server">>, SHost | RPath] = Path,
|
|||||||
end;
|
end;
|
||||||
false -> ejabberd_web:error(not_found)
|
false -> ejabberd_web:error(not_found)
|
||||||
end;
|
end;
|
||||||
process(RPath,
|
process2(RPath,
|
||||||
#request{auth = Auth, lang = Lang, host = HostHTTP,
|
#request{auth = Auth, lang = Lang, host = HostHTTP,
|
||||||
method = Method} =
|
method = Method} =
|
||||||
Request) ->
|
Request) ->
|
||||||
|
Loading…
Reference in New Issue
Block a user