Diff

plugins/muc/muc.lib.lua @ 3580:39547152bb72

MUC: Handle missing <value/> for <field type='boolean'/> in config form submissions.
author Waqas Hussain <waqas20@gmail.com>
date Wed, 10 Nov 2010 00:24:17 +0500
parent 3540:bc139431830b
child 3590:dcc5f3402f5b
line wrap: on
line diff
--- a/plugins/muc/muc.lib.lua	Tue Nov 09 20:23:28 2010 +0500
+++ b/plugins/muc/muc.lib.lua	Wed Nov 10 00:24:17 2010 +0500
@@ -601,8 +601,12 @@
 	if form.attr.type ~= "submit" then origin.send(st.error_reply(stanza, "cancel", "bad-request")); return; end
 	local fields = {};
 	for _, field in pairs(form.tags) do
-		if field.name == "field" and field.attr.var and field.tags[1].name == "value" and #field.tags[1].tags == 0 then
-			fields[field.attr.var] = field.tags[1][1] or "";
+		if field.name == "field" and field.attr.var then
+			if field.tags[1] and field.tags[1].name == "value" and #field.tags[1].tags == 0 then
+				fields[field.attr.var] = field.tags[1][1] or "";
+			elseif field.attr.type == "boolean" then
+				fields[field.attr.var] = "false";
+			end
 		end
 	end
 	if fields.FORM_TYPE ~= "http://jabber.org/protocol/muc#roomconfig" then origin.send(st.error_reply(stanza, "cancel", "bad-request")); return; end