Comparison

core/stanza_router.lua @ 7740:26a7186a40c6

core.stanza_router: Separate iq type check from child count check
author Kim Alvefur <zash@zash.se>
date Fri, 25 Nov 2016 05:08:09 +0100
parent 7739:0356216c474c
child 7785:cdffbda59b03
comparison
equal deleted inserted replaced
7739:0356216c474c 7740:26a7186a40c6
65 local name, st_type = stanza.name, stanza.attr.type; 65 local name, st_type = stanza.name, stanza.attr.type;
66 if st_type == "error" and #stanza.tags == 0 then 66 if st_type == "error" and #stanza.tags == 0 then
67 return handle_unhandled_stanza(origin.host, origin, stanza); 67 return handle_unhandled_stanza(origin.host, origin, stanza);
68 end 68 end
69 if name == "iq" then 69 if name == "iq" then
70 if not iq_types[st_type] or ((st_type == "set" or st_type == "get") and (#stanza.tags ~= 1)) then 70 if not iq_types[st_type] then
71 origin.send(st.error_reply(stanza, "modify", "bad-request", "Invalid IQ type or incorrect number of children")); 71 origin.send(st.error_reply(stanza, "modify", "bad-request", "Invalid IQ type"));
72 return; 72 return;
73 elseif not stanza.attr.id then 73 elseif not stanza.attr.id then
74 origin.send(st.error_reply(stanza, "modify", "bad-request", "Missing required 'id' attribute")); 74 origin.send(st.error_reply(stanza, "modify", "bad-request", "Missing required 'id' attribute"));
75 return;
76 elseif (st_type == "set" or st_type == "get") and (#stanza.tags ~= 1) then
77 origin.send(st.error_reply(stanza, "modify", "bad-request", "Incorrect number of children for IQ stanz"));
75 return; 78 return;
76 end 79 end
77 end 80 end
78 81
79 if not origin.full_jid 82 if not origin.full_jid