MUC: Process only options that are included in a form (Fixes #521)
authorKim Alvefur <zash@zash.se>
Tue, 08 Dec 2015 20:19:30 +0100
changeset 6985 c515f9491ce6
parent 6984 bcaa553de6e8
child 6986 05ef46379165
MUC: Process only options that are included in a form (Fixes #521)
plugins/muc/muc.lib.lua
--- a/plugins/muc/muc.lib.lua	Tue Dec 08 20:16:49 2015 +0100
+++ b/plugins/muc/muc.lib.lua	Tue Dec 08 20:19:30 2015 +0100
@@ -674,7 +674,7 @@
 	if form.attr.type == "cancel" then origin.send(st.reply(stanza)); return; end
 	if form.attr.type ~= "submit" then origin.send(st.error_reply(stanza, "cancel", "bad-request", "Not a submitted form")); return; end
 
-	local fields = self:get_form_layout(stanza.attr.from):data(form);
+	local fields, errors, present = self:get_form_layout(stanza.attr.from):data(form);
 	if fields.FORM_TYPE ~= "http://jabber.org/protocol/muc#roomconfig" then
 		origin.send(st.error_reply(stanza, "cancel", "bad-request", "Form is not of type room configuration"));
 		return;
@@ -683,8 +683,8 @@
 	local changed = {};
 
 	local function handle_option(name, field, allowed)
-		local new = fields[field];
-		if new == nil then return; end
+		local new, err, included = fields[field], errors[field], present[field];
+		if not included then return; end
 		if allowed and not allowed[new] then return; end
 		if new == self["get_"..name](self) then return; end
 		changed[name] = true;