39 if error == "no-stream" then |
39 if error == "no-stream" then |
40 session.log("debug", "Invalid opening stream header"); |
40 session.log("debug", "Invalid opening stream header"); |
41 session:close("invalid-namespace"); |
41 session:close("invalid-namespace"); |
42 elseif error == "parse-error" then |
42 elseif error == "parse-error" then |
43 (session.log or log)("debug", "Client XML parse error: %s", tostring(data)); |
43 (session.log or log)("debug", "Client XML parse error: %s", tostring(data)); |
44 session:close("xml-not-well-formed"); |
44 session:close("not-well-formed"); |
45 elseif error == "stream-error" then |
45 elseif error == "stream-error" then |
46 local condition, text = "undefined-condition"; |
46 local condition, text = "undefined-condition"; |
47 for child in data:children() do |
47 for child in data:children() do |
48 if child.attr.xmlns == xmlns_xmpp_streams then |
48 if child.attr.xmlns == xmlns_xmpp_streams then |
49 if child.name ~= "text" then |
49 if child.name ~= "text" then |
146 data = filter("bytes/in", data); |
146 data = filter("bytes/in", data); |
147 if data then |
147 if data then |
148 local ok, err = stream:feed(data); |
148 local ok, err = stream:feed(data); |
149 if ok then return; end |
149 if ok then return; end |
150 log("debug", "Received invalid XML (%s) %d bytes: %s", tostring(err), #data, data:sub(1, 300):gsub("[\r\n]+", " "):gsub("[%z\1-\31]", "_")); |
150 log("debug", "Received invalid XML (%s) %d bytes: %s", tostring(err), #data, data:sub(1, 300):gsub("[\r\n]+", " "):gsub("[%z\1-\31]", "_")); |
151 session:close("xml-not-well-formed"); |
151 session:close("not-well-formed"); |
152 end |
152 end |
153 end |
153 end |
154 |
154 |
155 local handlestanza = stream_callbacks.handlestanza; |
155 local handlestanza = stream_callbacks.handlestanza; |
156 function session.dispatch_stanza(session, stanza) |
156 function session.dispatch_stanza(session, stanza) |