plugins/muc/muc.lib.lua
changeset 10365 6e051bfca12d
parent 10357 7b602e13c3b6
child 10438 8f709577fe8e
--- a/plugins/muc/muc.lib.lua	Mon Sep 09 22:32:01 2019 +0200
+++ b/plugins/muc/muc.lib.lua	Mon Sep 23 19:13:14 2019 +0200
@@ -444,6 +444,22 @@
 	end
 end, 1);
 
+module:hook("muc-occupant-pre-join", function(event)
+	local nick = jid_resource(event.occupant.nick);
+	if not resourceprep(nick, true) then -- strict
+		event.origin.send(st.error_reply(event.stanza, "modify", "jid-malformed", "Nickname must pass strict validation"));
+		return true;
+	end
+end, 2);
+
+module:hook("muc-occupant-pre-change", function(event)
+	local nick = jid_resource(event.dest_occupant.nick);
+	if not resourceprep(nick, true) then -- strict
+		event.origin.send(st.error_reply(event.stanza, "modify", "jid-malformed", "Nickname must pass strict validation"));
+		return true;
+	end
+end, 2);
+
 function room_mt:handle_first_presence(origin, stanza)
 	local real_jid = stanza.attr.from;
 	local dest_jid = stanza.attr.to;