# HG changeset patch # User Waqas Hussain # Date 1223497128 -18000 # Node ID 79608fc8f98dfce2fbb8e5fc4011f8f8d3e066da # Parent a1f4f3c5ae251e468c023168af97f857f69e20da Fixed routing for IQs to bare JIDs, and added a simple IQ validity check diff -r a1f4f3c5ae25 -r 79608fc8f98d core/stanza_router.lua --- a/core/stanza_router.lua Wed Oct 08 17:27:20 2008 +0100 +++ b/core/stanza_router.lua Thu Oct 09 01:18:48 2008 +0500 @@ -16,9 +16,12 @@ function core_process_stanza(origin, stanza) log("debug", "Received: "..tostring(stanza)) -- TODO verify validity of stanza (as well as JID validity) + if stanza.name == "iq" and not(#stanza.tags == 1 and stanza.tags[1].attr.xmlns) then + error("Invalid IQ"); + end if origin.type == "c2s" and not origin.full_jid - and not(stanza.name == "iq" and stanza.tags[1] and stanza.tags[1].name == "bind" + and not(stanza.name == "iq" and stanza.tags[1].name == "bind" and stanza.tags[1].attr.xmlns == "urn:ietf:params:xml:ns:xmpp-bind") then error("Client MUST bind resource after auth"); end @@ -29,6 +32,8 @@ if not to or (hosts[to] and hosts[to].type == "local") then core_handle_stanza(origin, stanza); + elseif to and stanza.name == "iq" and not select(3, jid_split(to)) then + core_handle_stanza(origin, stanza); elseif origin.type == "c2s" then core_route_stanza(origin, stanza); end