mod_c2s: Iterate over child tags instead of child nodes in stream error (fixes traceback from #987)
authorKim Alvefur <zash@zash.se>
Wed, 13 Sep 2017 18:18:57 +0200
changeset 8235 176b7f4e4ac9
parent 8227 776789a98047
child 8236 4e7269c53659
mod_c2s: Iterate over child tags instead of child nodes in stream error (fixes traceback from #987)
plugins/mod_c2s.lua
--- a/plugins/mod_c2s.lua	Tue Jul 25 13:25:49 2017 +0200
+++ b/plugins/mod_c2s.lua	Wed Sep 13 18:18:57 2017 +0200
@@ -98,16 +98,14 @@
 		session:close("not-well-formed");
 	elseif error == "stream-error" then
 		local condition, text = "undefined-condition";
-		for child in data:children() do
-			if child.attr.xmlns == xmlns_xmpp_streams then
-				if child.name ~= "text" then
-					condition = child.name;
-				else
-					text = child:get_text();
-				end
-				if condition ~= "undefined-condition" and text then
-					break;
-				end
+		for child in data:childtags(nil, xmlns_xmpp_streams) do
+			if child.name ~= "text" then
+				condition = child.name;
+			else
+				text = child:get_text();
+			end
+			if condition ~= "undefined-condition" and text then
+				break;
 			end
 		end
 		text = condition .. (text and (" ("..text..")") or "");