Software /
code /
prosody
Diff
plugins/muc/muc.lib.lua @ 10361:6e051bfca12d
MUC: Enforce strict resourceprep on nicknames (bye bye robot face)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 23 Sep 2019 19:13:14 +0200 |
parent | 10353:7b602e13c3b6 |
child | 10434:8f709577fe8e |
line wrap: on
line diff
--- 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;