25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +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,9 +638,7 @@ is_ptype_match(Item, PType) ->
ljid(), none | both | from | to, [binary()]) -> boolean(). ljid(), none | both | from | to, [binary()]) -> boolean().
is_type_match(none, _Value, _JID, _Subscription, _Groups) -> is_type_match(none, _Value, _JID, _Subscription, _Groups) ->
true; true;
is_type_match(Type, Value, JID, Subscription, Groups) -> is_type_match(jid, Value, JID, _Subscription, _Groups) ->
case Type of
jid ->
case Value of case Value of
{<<"">>, Server, <<"">>} -> {<<"">>, Server, <<"">>} ->
case JID of case JID of
@ -652,11 +650,17 @@ is_type_match(Type, Value, JID, Subscription, Groups) ->
{User, Server, _} -> true; {User, Server, _} -> true;
_ -> false _ -> false
end; end;
{<<"">>, Server, Resource} ->
case JID of
{_, Server, Resource} -> true;
_ -> false
end;
_ -> Value == JID _ -> Value == JID
end; end;
subscription -> Value == Subscription; is_type_match(subscription, Value, _JID, Subscription, _Groups) ->
group -> lists:member(Value, Groups) Value == Subscription;
end. is_type_match(group, Group, _JID, _Subscription, Groups) ->
lists:member(Group, Groups).
-spec remove_user(binary(), binary()) -> ok. -spec remove_user(binary(), binary()) -> ok.
remove_user(User, Server) -> remove_user(User, Server) ->

View File

@ -258,7 +258,8 @@ master_slave_cases() ->
{privacy_master_slave, [sequence], {privacy_master_slave, [sequence],
[master_slave_test(deny_bare_jid), [master_slave_test(deny_bare_jid),
master_slave_test(deny_full_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_group),
master_slave_test(deny_sub_both), master_slave_test(deny_sub_both),
master_slave_test(deny_sub_from), master_slave_test(deny_sub_from),
@ -285,11 +286,18 @@ deny_full_jid_master(Config) ->
deny_full_jid_slave(Config) -> deny_full_jid_slave(Config) ->
deny_slave(Config). deny_slave(Config).
deny_server_jid_master(Config) -> deny_server_bare_jid_master(Config) ->
{_, Server, _} = jid:tolower(?config(peer, Config)), {_, Server, _} = jid:tolower(?config(peer, Config)),
deny_master(Config, {jid, Server}). 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_slave(Config).
deny_group_master(Config) -> deny_group_master(Config) ->