From 5077d39600dbfa8ff2d343a4ef7d130504c9c19e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chmielowski?= Date: Thu, 14 Mar 2019 15:54:51 +0100 Subject: [PATCH] Add check for ljid when setting up subscribers --- src/mod_muc_room.erl | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/mod_muc_room.erl b/src/mod_muc_room.erl index 544816673..a048272ca 100644 --- a/src/mod_muc_room.erl +++ b/src/mod_muc_room.erl @@ -1689,7 +1689,12 @@ update_online_user(JID, #user{nick = Nick} = User, StateData) -> NewStateData. set_subscriber(JID, Nick, Nodes, StateData) -> - BareJID = jid:remove_resource(JID), + BareJID = case JID of + #jid{} -> jid:remove_resource(JID); + _ -> + ?ERROR_MSG("Invalid subscriber JID in set_subscriber ~p", [JID]), + jid:remove_resource(jid:make(JID)) + end, LBareJID = jid:tolower(BareJID), Subscribers = maps:put(LBareJID, #subscriber{jid = BareJID, @@ -3674,14 +3679,20 @@ set_opts([{Opt, Val} | Opts], StateData) -> {Subscribers, Nicks} = lists:foldl( fun({JID, Nick, Nodes}, {SubAcc, NickAcc}) -> - BareJID = jid:remove_resource(JID), - {maps:put( - jid:tolower(BareJID), - #subscriber{jid = BareJID, - nick = Nick, - nodes = Nodes}, - SubAcc), - maps:put(Nick, [jid:tolower(BareJID)], NickAcc)} + BareJID = case JID of + #jid{} -> jid:remove_resource(JID); + _ -> + ?ERROR_MSG("Invalid subscriber JID in set_opts ~p", [JID]), + jid:remove_resource(jid:make(JID)) + end, + LBareJID = jid:tolower(BareJID), + {maps:put( + LBareJID, + #subscriber{jid = BareJID, + nick = Nick, + nodes = Nodes}, + SubAcc), + maps:put(Nick, [LBareJID], NickAcc)} end, {#{}, #{}}, Val), StateData#state{subscribers = Subscribers, subscriber_nicks = Nicks};