core/xmlhandlers.lua

changeset 53
14ea0fe6ca86
parent 40
2c0147bbd81a
child 99
ba08b8a4eeef
equal deleted inserted replaced
52:93e468eb2ffb 53:14ea0fe6ca86
8 local m_random = math.random; 8 local m_random = math.random;
9 local t_insert = table.insert; 9 local t_insert = table.insert;
10 local t_remove = table.remove; 10 local t_remove = table.remove;
11 local t_concat = table.concat; 11 local t_concat = table.concat;
12 local t_concatall = function (t, sep) local tt = {}; for _, s in ipairs(t) do t_insert(tt, tostring(s)); end return t_concat(tt, sep); end 12 local t_concatall = function (t, sep) local tt = {}; for _, s in ipairs(t) do t_insert(tt, tostring(s)); end return t_concat(tt, sep); end
13 local sm_destroy_session = import("core.sessionmanager", "destroy_session");
13 14
14 local error = error; 15 local error = error;
15 16
16 module "xmlhandlers" 17 module "xmlhandlers"
17 18
58 t_insert(chardata, data); 59 t_insert(chardata, data);
59 end 60 end
60 end 61 end
61 function xml_handlers:EndElement(name) 62 function xml_handlers:EndElement(name)
62 curr_ns,name = name:match("^(.+):(%w+)$"); 63 curr_ns,name = name:match("^(.+):(%w+)$");
63 if (not stanza) or #stanza.last_add < 0 or (#stanza.last_add > 0 and name ~= stanza.last_add[#stanza.last_add].name) then error("XML parse error in client stream"); end 64 if (not stanza) or #stanza.last_add < 0 or (#stanza.last_add > 0 and name ~= stanza.last_add[#stanza.last_add].name) then
65 if name == "stream" then
66 log("debug", "Stream closed");
67 sm_destroy_session(session);
68 return;
69 else
70 error("XML parse error in client stream");
71 end
72 end
64 if stanza and #chardata > 0 then 73 if stanza and #chardata > 0 then
65 -- We have some character data in the buffer 74 -- We have some character data in the buffer
66 stanza:text(t_concat(chardata)); 75 stanza:text(t_concat(chardata));
67 chardata = {}; 76 chardata = {};
68 end 77 end

mercurial