changeset 22:0f42c9c8085a

Fix configure setting error and handle cancelling of configure.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 23 Oct 2010 02:31:09 +0200
parents e55b31f12f8c
children 5fc4ee90c1bc
files psgxs.js
diffstat 1 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/psgxs.js
+++ b/psgxs.js
@@ -793,6 +793,8 @@ function onIq(stanza) {
 				if (!config.enabled('config-node'))
 					return makeError(response, errors.owner.configure.node_configuration_not_supported.n);
 
+				var configure = pubsub.getChild('configure');
+
 				var nodeID = configure.getAttribute('node');
 				if (!nodeID)
 					return makeError(response, errors.nodeid_required.n);
@@ -804,7 +806,15 @@ function onIq(stanza) {
 					return makeError(response, errors.forbidden.n);
 
 				var x = configure.getChild('x', 'jabber:x:data');
-				if (!x || x.getAttribute(type) != 'submit')
+				if (!x)
+					return makeError(response, errors.bad_request.n);
+
+				var type = x.getAttribute('type');
+				if (type == 'cancel') {
+					conn.send(response);
+					return;
+				}
+				if (type != 'submit')
 					return makeError(response, errors.bad_request.n);
 
 				var form = forms.parse(x, true);