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 | 39a09669859afad63161cd5f0e42762404733b80 (patch) | |
tree | 201fc9d8c19404401696c0f10d7ade2650e771f6 /plugins/muc | |
parent | ef60c12bef4c6c461e05355f2fe036aac140ab33 (diff) | |
download | prosody-39a09669859afad63161cd5f0e42762404733b80.tar.gz prosody-39a09669859afad63161cd5f0e42762404733b80.zip |
MUC: Enforce strict resourceprep on nicknames (bye bye robot face)
Diffstat (limited to 'plugins/muc')
-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; |