Software /
code /
prosody-modules
Comparison
mod_delegation/mod_delegation.lua @ 1723:ef85c42ad977
mod_delegation: fixed bad handling of error replies from managing entity
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 04 May 2015 18:44:00 +0200 |
parent | 1722:c48c7f948cfb |
child | 1724:2440a75e868f |
comparison
equal
deleted
inserted
replaced
1722:c48c7f948cfb | 1723:ef85c42ad977 |
---|---|
181 stanza_cache[stanza.attr.from][stanza.attr.id] = nil | 181 stanza_cache[stanza.attr.from][stanza.attr.id] = nil |
182 return true | 182 return true |
183 end | 183 end |
184 | 184 |
185 local iq = forwarded.tags[1] | 185 local iq = forwarded.tags[1] |
186 if #forwarded ~= 1 or iq.name ~= "iq" or #iq ~= 1 then | 186 if #forwarded ~= 1 or iq.name ~= "iq" or |
187 (iq.attr.type =='result' and #iq ~= 1) or | |
188 (iq.attr.type == 'error' and #iq > 2) then | |
187 module:log("warn", "ignoring invalid iq result from managing entity %s", stanza.attr.from) | 189 module:log("warn", "ignoring invalid iq result from managing entity %s", stanza.attr.from) |
188 stanza_cache[stanza.attr.from][stanza.attr.id] = nil | 190 stanza_cache[stanza.attr.from][stanza.attr.id] = nil |
189 return true | 191 return true |
190 end | 192 end |
191 | 193 |
192 local namespace = iq.tags[1].xmlns | |
193 local ns_data = ns_delegations[namespace] | |
194 local original = stanza_cache[stanza.attr.from][stanza.attr.id] | 194 local original = stanza_cache[stanza.attr.from][stanza.attr.id] |
195 stanza_cache[stanza.attr.from][stanza.attr.id] = nil | 195 stanza_cache[stanza.attr.from][stanza.attr.id] = nil |
196 | 196 -- we get namespace from original and not iq |
197 if stanza.attr.from ~= ns_data.connected or iq.attr.type ~= "result" or | 197 -- because the namespace can be lacking in case of error |
198 local namespace = original.tags[1].attr.xmlns | |
199 local ns_data = ns_delegations[namespace] | |
200 | |
201 if stanza.attr.from ~= ns_data.connected or (iq.attr.type ~= "result" and iq.attr.type ~= "error") or | |
198 iq.attr.id ~= original.attr.id or iq.attr.to ~= original.attr.from then | 202 iq.attr.id ~= original.attr.id or iq.attr.to ~= original.attr.from then |
199 module:log("warn", "ignoring forbidden iq result from managing entity %s, please check that the component is no trying to do something bad (stanza: %s)", stanza.attr.from, tostring(stanza)) | 203 module:log("warn", "ignoring forbidden iq result from managing entity %s, please check that the component is no trying to do something bad (stanza: %s)", stanza.attr.from, tostring(stanza)) |
200 module:send(st.error_reply(original, 'cancel', 'service-unavailable')) | 204 module:send(st.error_reply(original, 'cancel', 'service-unavailable')) |
201 return true | 205 return true |
202 end | 206 end |