Merge 0.10->trunk
[prosody.git] / plugins / mod_c2s.lua
index f0cdd7fb1044a71952d48597387d91f50bd98575..4238b2e7e1f3b729450dcccd845477f9065ff62e 100644 (file)
@@ -91,7 +91,7 @@ end
 
 function stream_callbacks.error(session, error, data)
        if error == "no-stream" then
-               session.log("debug", "Invalid opening stream header");
+               session.log("debug", "Invalid opening stream header (%s)", (data:gsub("^([^\1]+)\1", "{%1}")));
                session:close("invalid-namespace");
        elseif error == "parse-error" then
                (session.log or log)("debug", "Client XML parse error: %s", tostring(data));
@@ -240,9 +240,9 @@ function listener.onconnect(conn)
        function session.data(data)
                -- Parse the data, which will store stanzas in session.pending_stanzas
                if data then
-                       data = filter("bytes/in", data);
-                       if data then
-                               local ok, err = stream:feed(data);
+               data = filter("bytes/in", data);
+               if data then
+                       local ok, err = stream:feed(data);
                                if not ok then
                                        log("debug", "Received invalid XML (%s) %d bytes: %s", tostring(err), #data, data:sub(1, 300):gsub("[\r\n]+", " "):gsub("[%z\1-\31]", "_"));
                                        session:close("not-well-formed");