25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-20 17:27:00 +01:00

Explicitly match against <domain/resource>

Fixes #1958
This commit is contained in:
Evgeniy Khramtsov 2017-08-23 09:00:13 +03:00
parent 350827f8f4
commit 47175adc74
2 changed files with 34 additions and 22 deletions

View File

@ -638,25 +638,29 @@ is_ptype_match(Item, PType) ->
ljid(), none | both | from | to, [binary()]) -> boolean().
is_type_match(none, _Value, _JID, _Subscription, _Groups) ->
true;
is_type_match(Type, Value, JID, Subscription, Groups) ->
case Type of
jid ->
case Value of
{<<"">>, Server, <<"">>} ->
case JID of
{_, Server, _} -> true;
_ -> false
end;
{User, Server, <<"">>} ->
case JID of
{User, Server, _} -> true;
_ -> false
end;
_ -> Value == JID
end;
subscription -> Value == Subscription;
group -> lists:member(Value, Groups)
end.
is_type_match(jid, Value, JID, _Subscription, _Groups) ->
case Value of
{<<"">>, Server, <<"">>} ->
case JID of
{_, Server, _} -> true;
_ -> false
end;
{User, Server, <<"">>} ->
case JID of
{User, Server, _} -> true;
_ -> false
end;
{<<"">>, Server, Resource} ->
case JID of
{_, Server, Resource} -> true;
_ -> false
end;
_ -> Value == JID
end;
is_type_match(subscription, Value, _JID, Subscription, _Groups) ->
Value == Subscription;
is_type_match(group, Group, _JID, _Subscription, Groups) ->
lists:member(Group, Groups).
-spec remove_user(binary(), binary()) -> ok.
remove_user(User, Server) ->

View File

@ -258,7 +258,8 @@ master_slave_cases() ->
{privacy_master_slave, [sequence],
[master_slave_test(deny_bare_jid),
master_slave_test(deny_full_jid),
master_slave_test(deny_server_jid),
master_slave_test(deny_server_bare_jid),
master_slave_test(deny_server_full_jid),
master_slave_test(deny_group),
master_slave_test(deny_sub_both),
master_slave_test(deny_sub_from),
@ -285,11 +286,18 @@ deny_full_jid_master(Config) ->
deny_full_jid_slave(Config) ->
deny_slave(Config).
deny_server_jid_master(Config) ->
deny_server_bare_jid_master(Config) ->
{_, Server, _} = jid:tolower(?config(peer, Config)),
deny_master(Config, {jid, Server}).
deny_server_jid_slave(Config) ->
deny_server_bare_jid_slave(Config) ->
deny_slave(Config).
deny_server_full_jid_master(Config) ->
{_, Server, Resource} = jid:tolower(?config(peer, Config)),
deny_master(Config, {jid, jid:encode({<<"">>, Server, Resource})}).
deny_server_full_jid_slave(Config) ->
deny_slave(Config).
deny_group_master(Config) ->