xmlhandlers: Move stream-error detection to somewhere more appropriate (it was never reached) - s2s stream errors now reported properly

Tue, 19 Jan 2010 03:58:20 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Tue, 19 Jan 2010 03:58:20 +0000
changeset 2468
68bb1cc1a8b0
parent 2467
8098310d0dfd
child 2469
9e0c0b08f219

xmlhandlers: Move stream-error detection to somewhere more appropriate (it was never reached) - s2s stream errors now reported properly

core/xmlhandlers.lua file | annotate | diff | comparison | revisions
--- a/core/xmlhandlers.lua	Tue Jan 19 03:57:19 2010 +0000
+++ b/core/xmlhandlers.lua	Tue Jan 19 03:58:20 2010 +0000
@@ -116,13 +116,11 @@
 			if name == "" then
 				curr_ns, name = "", curr_ns;
 			end
-			if (not stanza) or (#stanza.last_add > 0 and name ~= stanza.last_add[#stanza.last_add].name) then 
+			if not stanza then
 				if tagname == stream_tag then
 					if cb_streamclosed then
 						cb_streamclosed(session);
 					end
-				elseif name == "error" then
-					cb_error(session, "stream-error", stanza);
 				else
 					cb_error(session, "parse-error", "unexpected-element-close", name);
 				end
@@ -136,7 +134,11 @@
 			end
 			-- Complete stanza
 			if #stanza.last_add == 0 then
-				cb_handlestanza(session, stanza);
+				if tagname ~= stream_error_tag then
+					cb_handlestanza(session, stanza);
+				else
+					cb_error(session, "stream-error", stanza);
+				end
 				stanza = nil;
 			else
 				stanza:up();

mercurial