From 212ff87e61748fe14571202b1ab85fc7d1e5c2a1 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Fri, 25 Nov 2016 05:08:09 +0100 Subject: core.stanza_router: Separate iq type check from child count check --- core/stanza_router.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/stanza_router.lua b/core/stanza_router.lua index 2fb480ee..af797f08 100644 --- a/core/stanza_router.lua +++ b/core/stanza_router.lua @@ -67,12 +67,15 @@ function core_process_stanza(origin, stanza) return handle_unhandled_stanza(origin.host, origin, stanza); end if name == "iq" then - if not iq_types[st_type] or ((st_type == "set" or st_type == "get") and (#stanza.tags ~= 1)) then - origin.send(st.error_reply(stanza, "modify", "bad-request", "Invalid IQ type or incorrect number of children")); + if not iq_types[st_type] then + origin.send(st.error_reply(stanza, "modify", "bad-request", "Invalid IQ type")); return; elseif not stanza.attr.id then origin.send(st.error_reply(stanza, "modify", "bad-request", "Missing required 'id' attribute")); return; + elseif (st_type == "set" or st_type == "get") and (#stanza.tags ~= 1) then + origin.send(st.error_reply(stanza, "modify", "bad-request", "Incorrect number of children for IQ stanz")); + return; end end -- cgit v1.2.3