From 05f3218e101d65f7628e38f3b5b9e686fe6f46e4 Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Sat, 23 Jan 2010 18:41:20 +0500 Subject: xmlhandlers: Rearranged a little code. --- core/xmlhandlers.lua | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'core') diff --git a/core/xmlhandlers.lua b/core/xmlhandlers.lua index 85ce1040..3d6ace12 100644 --- a/core/xmlhandlers.lua +++ b/core/xmlhandlers.lua @@ -116,7 +116,24 @@ function init_xmlhandlers(session, stream_callbacks) if name == "" then curr_ns, name = "", curr_ns; end - if not stanza then + if stanza then + if #chardata > 0 then + -- We have some character data in the buffer + stanza:text(t_concat(chardata)); + chardata = {}; + end + -- Complete stanza + if #stanza.last_add == 0 then + if tagname ~= stream_error_tag then + cb_handlestanza(session, stanza); + else + cb_error(session, "stream-error", stanza); + end + stanza = nil; + else + stanza:up(); + end + else if tagname == stream_tag then if cb_streamclosed then cb_streamclosed(session); @@ -125,23 +142,6 @@ function init_xmlhandlers(session, stream_callbacks) cb_error(session, "parse-error", "unexpected-element-close", name); end stanza, chardata = nil, {}; - return; - end - if #chardata > 0 then - -- We have some character data in the buffer - stanza:text(t_concat(chardata)); - chardata = {}; - end - -- Complete stanza - if #stanza.last_add == 0 then - if tagname ~= stream_error_tag then - cb_handlestanza(session, stanza); - else - cb_error(session, "stream-error", stanza); - end - stanza = nil; - else - stanza:up(); end end return xml_handlers; -- cgit v1.2.3