Software /
code /
prosody
Comparison
core/stanza_router.lua @ 1899:ccb7d9ccbf24
stanza_router: Reply to IQ requests with missing 'id' attribute with a bad-request error.
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Sun, 04 Oct 2009 21:46:35 +0500 |
parent | 1609:95d3bcd82334 |
child | 1900:93a94ec05ebe |
comparison
equal
deleted
inserted
replaced
1898:1ce02e2f5a3f | 1899:ccb7d9ccbf24 |
---|---|
24 if not stanza.attr.xmlns then stanza.attr.xmlns = "jabber:client"; end | 24 if not stanza.attr.xmlns then stanza.attr.xmlns = "jabber:client"; end |
25 | 25 |
26 -- TODO verify validity of stanza (as well as JID validity) | 26 -- TODO verify validity of stanza (as well as JID validity) |
27 if stanza.attr.type == "error" and #stanza.tags == 0 then return; end -- TODO invalid stanza, log | 27 if stanza.attr.type == "error" and #stanza.tags == 0 then return; end -- TODO invalid stanza, log |
28 if stanza.name == "iq" then | 28 if stanza.name == "iq" then |
29 if (stanza.attr.type == "set" or stanza.attr.type == "get") and #stanza.tags ~= 1 then | 29 local can_reply = stanza.attr.type == "set" or stanza.attr.type == "get" |
30 local missing_id = not stanza.attr.id; | |
31 if can_reply and (#stanza.tags ~= 1 or missing_id) then | |
30 origin.send(st.error_reply(stanza, "modify", "bad-request")); | 32 origin.send(st.error_reply(stanza, "modify", "bad-request")); |
33 return; | |
34 elseif missing_id then | |
31 return; | 35 return; |
32 end | 36 end |
33 end | 37 end |
34 | 38 |
35 if origin.type == "c2s" then | 39 if origin.type == "c2s" then |