diff options
Diffstat (limited to 'core/xmlhandlers.lua')
-rw-r--r-- | core/xmlhandlers.lua | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/core/xmlhandlers.lua b/core/xmlhandlers.lua index 020e08db..56115917 100644 --- a/core/xmlhandlers.lua +++ b/core/xmlhandlers.lua @@ -121,17 +121,19 @@ function init_xmlhandlers(session, stream_callbacks) cb_error(session, "parse-error", "unexpected-element-close", name); end end - if stanza and #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 - cb_handlestanza(session, stanza); - stanza = nil; - else - stanza:up(); + if stanza then + if stanza and #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 + cb_handlestanza(session, stanza); + stanza = nil; + else + stanza:up(); + end end end return xml_handlers; |