changeset 3394:4fe7eee926ce

Merge with goffi
author Kim Alvefur <zash@zash.se>
date Sat, 01 Dec 2018 17:52:17 +0100
parents 8d1141025b43 (current diff) 7454274ead2f (diff)
children eaf0b1e95016
files
diffstat 1 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mod_privilege/mod_privilege.lua	Sat Dec 01 16:04:35 2018 +0100
+++ b/mod_privilege/mod_privilege.lua	Sat Dec 01 17:52:17 2018 +0100
@@ -332,6 +332,19 @@
 
 --> message permission <--
 
+local function clean_xmlns(node)
+	-- Recursively remove "jabber:client" attribute from node.
+	-- In Prosody internal routing, xmlns should not be set.
+	-- Keeping xmlns would lead to issues like mod_smacks ignoring the outgoing stanza,
+	-- so we remove all xmlns attributes with a value of "jabber:client"
+	if node.attr.xmlns == 'jabber:client' then
+		for childnode in node:childtags() do
+			clean_xmlns(childnode);
+		end
+		node.attr.xmlns = nil;
+	end
+end
+
 module:hook("message/host", function(event)
 	local session, stanza = event.origin, event.stanza;
 	local privilege_elt = stanza:get_child('privilege', _PRIV_ENT_NS)
@@ -346,6 +359,7 @@
 			if message_elt ~= nil then
 				local _, from_host, from_resource = jid.split(message_elt.attr.from)
 				if from_resource == nil and hosts[from_host] then -- we only accept bare jids from one of the server hosts
+					clean_xmlns(message_elt);  -- needed do to proper routing
 					-- at this point everything should be alright, we can send the message
 					prosody.core_route_stanza(nil, message_elt)
 				else -- trying to send a message from a forbidden entity