Comparison

core/xmlhandlers.lua @ 2468:68bb1cc1a8b0

xmlhandlers: Move stream-error detection to somewhere more appropriate (it was never reached) - s2s stream errors now reported properly
author Matthew Wild <mwild1@gmail.com>
date Tue, 19 Jan 2010 03:58:20 +0000
parent 2464:0b5f0ae7a6b1
child 2492:b5e2d1919ec3
comparison
equal deleted inserted replaced
2467:8098310d0dfd 2468:68bb1cc1a8b0
114 function xml_handlers:EndElement(tagname) 114 function xml_handlers:EndElement(tagname)
115 local curr_ns,name = tagname:match(ns_pattern); 115 local curr_ns,name = tagname:match(ns_pattern);
116 if name == "" then 116 if name == "" then
117 curr_ns, name = "", curr_ns; 117 curr_ns, name = "", curr_ns;
118 end 118 end
119 if (not stanza) or (#stanza.last_add > 0 and name ~= stanza.last_add[#stanza.last_add].name) then 119 if not stanza then
120 if tagname == stream_tag then 120 if tagname == stream_tag then
121 if cb_streamclosed then 121 if cb_streamclosed then
122 cb_streamclosed(session); 122 cb_streamclosed(session);
123 end 123 end
124 elseif name == "error" then
125 cb_error(session, "stream-error", stanza);
126 else 124 else
127 cb_error(session, "parse-error", "unexpected-element-close", name); 125 cb_error(session, "parse-error", "unexpected-element-close", name);
128 end 126 end
129 stanza, chardata = nil, {}; 127 stanza, chardata = nil, {};
130 return; 128 return;
134 stanza:text(t_concat(chardata)); 132 stanza:text(t_concat(chardata));
135 chardata = {}; 133 chardata = {};
136 end 134 end
137 -- Complete stanza 135 -- Complete stanza
138 if #stanza.last_add == 0 then 136 if #stanza.last_add == 0 then
139 cb_handlestanza(session, stanza); 137 if tagname ~= stream_error_tag then
138 cb_handlestanza(session, stanza);
139 else
140 cb_error(session, "stream-error", stanza);
141 end
140 stanza = nil; 142 stanza = nil;
141 else 143 else
142 stanza:up(); 144 stanza:up();
143 end 145 end
144 end 146 end