net/xmppclient_listener.lua

changeset 3144
9e16012c2155
parent 3136
9630cb97cd3e
child 3332
c941d1191709
equal deleted inserted replaced
3143:887a6374f51c 3144:9e16012c2155
136 function session.reset_stream() 136 function session.reset_stream()
137 session.notopen = true; 137 session.notopen = true;
138 session.stream:reset(); 138 session.stream:reset();
139 end 139 end
140 140
141 local filter = session.filter;
141 function session.data(data) 142 function session.data(data)
142 local ok, err = stream:feed(data); 143 data = filter("bytes/in", data);
143 if ok then return; end 144 if data then
144 log("debug", "Received invalid XML (%s) %d bytes: %s", tostring(err), #data, data:sub(1, 300):gsub("[\r\n]+", " "):gsub("[%z\1-\31]", "_")); 145 local ok, err = stream:feed(data);
145 session:close("xml-not-well-formed"); 146 if ok then return; end
147 log("debug", "Received invalid XML (%s) %d bytes: %s", tostring(err), #data, data:sub(1, 300):gsub("[\r\n]+", " "):gsub("[%z\1-\31]", "_"));
148 session:close("xml-not-well-formed");
149 end
146 end 150 end
147 151
148 session.dispatch_stanza = stream_callbacks.handlestanza; 152 local handlestanza = stream_callbacks.handlestanza;
153 function session.dispatch_stanza(session, stanza)
154 stanza = filter("stanzas/in", stanza);
155 if stanza then
156 return handlestanza(session, stanza);
157 end
158 end
149 end 159 end
150 160
151 function xmppclient.onincoming(conn, data) 161 function xmppclient.onincoming(conn, data)
152 local session = sessions[conn]; 162 local session = sessions[conn];
153 if session then 163 if session then

mercurial