Extra checks before sending error replies to incoming stanzas

Wed, 19 Nov 2008 05:09:05 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Wed, 19 Nov 2008 05:09:05 +0000
changeset 340
a31715bf08eb
parent 339
c6446bbfe40c
child 341
a9e02b5c58d2

Extra checks before sending error replies to incoming stanzas

core/stanza_router.lua file | annotate | diff | comparison | revisions
--- a/core/stanza_router.lua	Wed Nov 19 05:07:52 2008 +0000
+++ b/core/stanza_router.lua	Wed Nov 19 05:09:05 2008 +0000
@@ -35,7 +35,7 @@
 local print = print;
 
 function core_process_stanza(origin, stanza)
-	log("debug", "Received[%s]: %s", origin.type, stanza:pretty_top_tag())
+	(origin.log or log)("debug", "Received[%s]: %s", origin.type, stanza:pretty_print()) --top_tag())
 
 	if not stanza.attr.xmlns then stanza.attr.xmlns = "jabber:client"; end -- FIXME Hack. This should be removed when we fix namespace handling.
 	-- TODO verify validity of stanza (as well as JID validity)
@@ -177,19 +177,19 @@
 				stanza.attr.to = nil; -- reset it
 			else
 				log("warn", "Unhandled c2s presence: %s", tostring(stanza));
-				if stanza.attr.type ~= "error" then
+				if (stanza.attr.xmlns == "jabber:client" or stanza.attr.xmlns == "jabber:server") and stanza.attr.type ~= "error" then
 					origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); -- FIXME correct error?
 				end
 			end
 		else
 			log("warn", "Unhandled c2s stanza: %s", tostring(stanza));
-			if stanza.attr.type ~= "error" and stanza.attr.type ~= "result" then
+			if (stanza.attr.xmlns == "jabber:client" or stanza.attr.xmlns == "jabber:server") and stanza.attr.type ~= "error" and stanza.attr.type ~= "result" then
 				origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); -- FIXME correct error?
 			end
 		end -- TODO handle other stanzas
 	else
 		log("warn", "Unhandled origin: %s", origin.type);
-		if stanza.attr.type ~= "error" and stanza.attr.type ~= "result" then
+		if (stanza.attr.xmlns == "jabber:client" or stanza.attr.xmlns == "jabber:server") and stanza.attr.type ~= "error" and stanza.attr.type ~= "result" then
 			-- s2s stanzas can get here
 			(origin.sends2s or origin.send)(st.error_reply(stanza, "cancel", "service-unavailable")); -- FIXME correct error?
 		end

mercurial