# HG changeset patch # User Waqas Hussain # Date 1264254080 -18000 # Node ID ec09d16a51e19f2ac7f2f229eb0ace8f20cf7e7d # Parent b5e2d1919ec34b117fa3e03fcf98f74c6524f6bb xmlhandlers: Rearranged a little code. diff -r b5e2d1919ec3 -r ec09d16a51e1 core/xmlhandlers.lua --- a/core/xmlhandlers.lua Sat Jan 23 18:33:39 2010 +0500 +++ b/core/xmlhandlers.lua Sat Jan 23 18:41:20 2010 +0500 @@ -116,7 +116,24 @@ 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 @@ 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;