(Basic) IDNA and SRV fallback support
[prosody.git] / core / xmlhandlers.lua
index 09139904c999ae97f36206a08c1414f9df7408a4..a97db8e91cc522732e312624653b4efb6e622c9f 100644 (file)
@@ -68,9 +68,10 @@ function init_xmlhandlers(session, stream_callbacks)
                        
                        if not stanza then --if we are not currently inside a stanza
                                if session.notopen then
-                                       print("client opening with "..tostring(name));
-                                       if name == "stream" and cb_streamopened then
-                                               cb_streamopened(session, attr);
+                                       if name == "stream" then
+                                               if cb_streamopened then
+                                                       cb_streamopened(session, attr);
+                                               end
                                                return;
                                        end
                                        error("Client failed to open stream successfully");
@@ -96,15 +97,17 @@ function init_xmlhandlers(session, stream_callbacks)
                end
                function xml_handlers:EndElement(name)
                        curr_ns,name = name:match("^(.+)|([%w%-]+)$");
-                       if (not stanza) or #stanza.last_add < 0 or (#stanza.last_add > 0 and name ~= stanza.last_add[#stanza.last_add].name) then 
-                               if name == "stream" and cb_streamclosed then
+                       if (not stanza) or (#stanza.last_add > 0 and name ~= stanza.last_add[#stanza.last_add].name) then 
+                               if name == "stream" then
                                        log("debug", "Stream closed");
-                                       cb_streamclosed(session);
+                                       if cb_streamclosed then
+                                               cb_streamclosed(session);
+                                       end
                                        return;
                                elseif name == "error" then
                                        error("Stream error: "..tostring(name)..": "..tostring(stanza));
                                else
-                                       error("XML parse error in client stream");
+                                       error("XML parse error in client stream with element: "..name);
                                end
                        end
                        if stanza and #chardata > 0 then