changeset 13876:3609d8fcad00 13.0

MUC: Ensure room-creating join stanza includes nickname (fix #1934) Prevents a traceback when attempting to validate an absent nickname.
author Kim Alvefur <zash@zash.se>
date Mon, 19 May 2025 18:12:57 +0200
parents 9a2075e3e383
children 4e109e917f89 cbb8dc92daa9
files plugins/muc/mod_muc.lua spec/scansion/muc_create_destroy.scs
diffstat 2 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/muc/mod_muc.lua	Mon May 19 18:11:27 2025 +0200
+++ b/plugins/muc/mod_muc.lua	Mon May 19 18:12:57 2025 +0200
@@ -104,6 +104,7 @@
 local jid_split = require "prosody.util.jid".split;
 local jid_prep = require "prosody.util.jid".prep;
 local jid_bare = require "prosody.util.jid".bare;
+local jid_resource = require "prosody.util.jid".resource;
 local st = require "prosody.util.stanza";
 local cache = require "prosody.util.cache";
 
@@ -444,6 +445,7 @@
 local function is_join_presence(stanza)
 	return stanza.name == "presence"
 		and stanza.attr.type == nil
+		and jid_resource(stanza.attr.to) ~= nil
 		and stanza:get_child("x", "http://jabber.org/protocol/muc");
 end
 
--- a/spec/scansion/muc_create_destroy.scs	Mon May 19 18:11:27 2025 +0200
+++ b/spec/scansion/muc_create_destroy.scs	Mon May 19 18:12:57 2025 +0200
@@ -17,6 +17,14 @@
 Romeo connects
 
 Romeo sends:
+	<presence to="garden@conference.localhost">
+		<x xmlns="http://jabber.org/protocol/muc"/>
+	</presence>
+
+Romeo receives:
+	<presence from="garden@conference.localhost" type="error"/>
+
+Romeo sends:
 	<presence to="garden@conference.localhost/romeo">
 		<x xmlns="http://jabber.org/protocol/muc"/>
 	</presence>