Changeset

8233:4e7269c53659

mod_component, mod_s2s: Iterate over child tags instead of child nodes (can include text) in stream error (same as 176b7f4e4ac9)
author Kim Alvefur <zash@zash.se>
date Thu, 14 Sep 2017 01:27:36 +0200
parents 8232:176b7f4e4ac9
children 8234:97b3ca502547 8465:0ec72e67f797
files plugins/mod_component.lua plugins/mod_s2s/mod_s2s.lua
diffstat 2 files changed, 16 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_component.lua	Wed Sep 13 18:18:57 2017 +0200
+++ b/plugins/mod_component.lua	Thu Sep 14 01:27:36 2017 +0200
@@ -151,16 +151,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 "");
--- a/plugins/mod_s2s/mod_s2s.lua	Wed Sep 13 18:18:57 2017 +0200
+++ b/plugins/mod_s2s/mod_s2s.lua	Thu Sep 14 01:27:36 2017 +0200
@@ -416,16 +416,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 "");