MUC: Be more careful with deserialization of rooms, fix case where a bare jid has...
[prosody.git] / plugins / muc / muc.lib.lua
index e98e99b8a50c8e1d1989e8bf798d5d731e4d7422..ce6c57840819c30010c87ccc5c18323e2064bcb1 100644 (file)
@@ -709,7 +709,7 @@ function room_mt:process_form(origin, stanza)
                end
                event.field, event.value = nil, nil;
 
-               self:save(true);
+               self:save();
                origin.send(st.reply(stanza));
 
                if next(event.status_codes) then
@@ -1159,7 +1159,7 @@ function room_mt:set_affiliation(actor, jid, affiliation, reason)
                end
        end
 
-       self:save(true);
+       self:save();
 
        module:fire_event("muc-set-affiliation", {
                room = self;
@@ -1283,10 +1283,10 @@ function _M.restore_room(frozen)
        for jid, data in pairs(frozen) do
                local node, host, resource = jid_split(jid);
                if node or host:sub(1,1) ~= "_" then
-                       if not resource then
+                       if not resource and type(data) == "string" then
                                -- bare jid: affiliation
                                room._affiliations[jid] = data;
-                       elseif host == room_host and node == room_name then
+                       elseif host == room_host and node == room_name and resource then
                                -- full room jid: bare real jid and role
                                local bare_jid = data.bare_jid;
                                local   occupant = occupant_lib.new(bare_jid, jid);