25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +01:00

* src/web/ejabberd_web_admin.erl: Fixed encoding of user names in

URLs

* src/web/ejabberd_http.erl: Added url_encode function from yaws

SVN Revision: 441
This commit is contained in:
Alexey Shchepin 2005-11-22 18:25:02 +00:00
parent f765d7f612
commit 3fdf05a507
3 changed files with 55 additions and 4 deletions

View File

@ -1,5 +1,10 @@
2005-11-22 Alexey Shchepin <alexey@sevcom.net>
* src/web/ejabberd_web_admin.erl: Fixed encoding of user names in
URLs
* src/web/ejabberd_http.erl: Added url_encode function from yaws
* src/ejabberd_c2s.erl: Send stream error when connection is
replaced (thanks to Maxim Ryazanov)

View File

@ -13,7 +13,8 @@
%% External exports
-export([start/2,
start_link/2,
receive_headers/1]).
receive_headers/1,
url_encode/1]).
-include("ejabberd.hrl").
-include("jlib.hrl").
@ -652,6 +653,46 @@ parse_urlencoded(undefined, _, _, _) ->
[].
url_encode([H|T]) ->
if
H >= $a, $z >= H ->
[H|url_encode(T)];
H >= $A, $Z >= H ->
[H|url_encode(T)];
H >= $0, $9 >= H ->
[H|url_encode(T)];
H == $_; H == $.; H == $-; H == $/; H == $: -> % FIXME: more..
[H|url_encode(T)];
true ->
case integer_to_hex(H) of
[X, Y] ->
[$%, X, Y | url_encode(T)];
[X] ->
[$%, $0, X | url_encode(T)]
end
end;
url_encode([]) ->
[].
integer_to_hex(I) ->
case catch erlang:integer_to_list(I, 16) of
{'EXIT', _} ->
old_integer_to_hex(I);
Int ->
Int
end.
old_integer_to_hex(I) when I<10 ->
integer_to_list(I);
old_integer_to_hex(I) when I<16 ->
[I-10+$A];
old_integer_to_hex(I) when I>=16 ->
N = trunc(I/16),
old_integer_to_hex(N) ++ old_integer_to_hex(I rem 16).
% The following code is mostly taken from yaws_ssl.erl
parse_request(State, Data) ->

View File

@ -1343,7 +1343,10 @@ list_given_users(Users, Prefix, Lang, URLFunc) ->
?T("Online")
end,
?XE("tr",
[?XE("td", [?AC(URLFunc({user, Prefix, User, Server}),
[?XE("td",
[?AC(URLFunc({user, Prefix,
ejabberd_http:url_encode(User),
Server}),
us_to_list(US))]),
?XE("td", FQueueLen),
?XC("td", FLast)])
@ -1397,7 +1400,9 @@ list_online_users(Host, _Lang) ->
SUsers = lists:usort(Users),
lists:flatmap(
fun({S, U} = SU) ->
[?AC("../user/" ++ U ++ "/", su_to_list(SU)), ?BR]
[?AC("../user/" ++ ejabberd_http:url_encode(U) ++ "/",
su_to_list(SU)),
?BR]
end, SUsers).
user_info(User, Server, Query, Lang) ->