mod_rest: Enforce single child policy for outgoing it stanzas
authorKim Alvefur <zash@zash.se>
Fri, 03 Jan 2020 18:29:10 +0100
changeset 3836 0d4146cf9fbc
parent 3835 435f5b4ebd06
child 3837 580862decd77
mod_rest: Enforce single child policy for outgoing it stanzas
mod_rest/mod_rest.lua
--- a/mod_rest/mod_rest.lua	Fri Jan 03 16:33:40 2020 +0100
+++ b/mod_rest/mod_rest.lua	Fri Jan 03 18:29:10 2020 +0100
@@ -106,6 +106,8 @@
 	if payload.name == "iq" then
 		if payload.attr.type ~= "get" and payload.attr.type ~= "set" then
 			return errors.new({ code = 422, text = "'iq' stanza must be of type 'get' or 'set'" });
+		elseif #payload.tags ~= 1 then
+			return errors.new({ code = 422, text = "'iq' stanza must have exactly one child tag" });
 		end
 		return module:send_iq(payload):next(
 			function (result)