# HG changeset patch # User Kim Alvefur # Date 1543683137 -3600 # Node ID 4fe7eee926ce9e194320a8d5ef6628aad070e46b # Parent 8d1141025b43809dfe26b2453941f930c3980e86# Parent 7454274ead2f207e4ab44f168e1e568cf00cb83c Merge with goffi diff -r 8d1141025b43 -r 4fe7eee926ce mod_privilege/mod_privilege.lua --- 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