diff plugins/mod_admin_shell.lua @ 13999:5ad86978ae78 13.0

mod_admin_shell: Ensure JIDs are normalized in xmpp:ping()
author Kim Alvefur <zash@zash.se>
date Fri, 05 Dec 2025 17:53:10 +0100
parents 8d90a83603d6
children 071779f7645c 2aeb5dcb36bf
line wrap: on
line diff
--- a/plugins/mod_admin_shell.lua	Mon Dec 01 16:35:11 2025 +0100
+++ b/plugins/mod_admin_shell.lua	Fri Dec 05 17:53:10 2025 +0100
@@ -2054,8 +2054,8 @@
 describe_command [[xmpp:ping(localjid, remotejid) - Sends a ping to an XMPP entity and reports the response]]
 local new_id = require "prosody.util.id".medium;
 function def_env.xmpp:ping(localjid, remotejid, timeout)
-	local localhost, localresource = select(2, jid_split(localjid));
-	local remotehost = select(2, jid_split(remotejid));
+	local localnode, localhost, localresource = jid_split(localjid);
+	local remotenode, remotehost, remoteresource = jid_split(remotejid);
 	if not localhost then
 		return nil, "Invalid sender JID";
 	elseif not prosody.hosts[localhost] then
@@ -2066,7 +2066,7 @@
 	if not remotehost then
 		return nil, "Invalid destination JID";
 	end
-	local iq = st.iq{ from=localjid, to=remotejid, type="get", id=new_id()}
+	local iq = st.iq { from = jid_join(localnode, localhost); to = jid_join(remotenode, remotehost, remoteresource); type = "get"; id = new_id() }
 			:tag("ping", {xmlns="urn:xmpp:ping"});
 	local time_start = time.now();
 	local print = self.session.print;