diff options
author | Kim Alvefur <zash@zash.se> | 2019-09-23 19:13:14 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2019-09-23 19:13:14 +0200 |
commit | 2834c8aaff68fc71a6ccba394c1c3ccbe06846a1 (patch) | |
tree | 201fc9d8c19404401696c0f10d7ade2650e771f6 | |
parent | c09d6decbebbaec23defaed760dcfc63a3c9ec32 (diff) | |
download | prosody-2834c8aaff68fc71a6ccba394c1c3ccbe06846a1.tar.gz prosody-2834c8aaff68fc71a6ccba394c1c3ccbe06846a1.zip |
MUC: Enforce strict resourceprep on nicknames (bye bye robot face)
-rw-r--r-- | plugins/muc/muc.lib.lua | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/plugins/muc/muc.lib.lua b/plugins/muc/muc.lib.lua index 200f69f9..3a228aae 100644 --- a/plugins/muc/muc.lib.lua +++ b/plugins/muc/muc.lib.lua @@ -444,6 +444,22 @@ module:hook("muc-occupant-pre-change", function(event) 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; |