Mercurial > prosody-hg
comparison 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 |
| parents | 7b602e13c3b6 |
| children | 8f709577fe8e |
comparison
equal
deleted
inserted
replaced
| 10360:64ddcbc9a328 | 10361:6e051bfca12d |
|---|---|
| 441 if not jid_resource(event.dest_occupant.nick):find("%S") then | 441 if not jid_resource(event.dest_occupant.nick):find("%S") then |
| 442 event.origin.send(st.error_reply(event.stanza, "modify", "not-allowed", "Invisible Nicknames are forbidden")); | 442 event.origin.send(st.error_reply(event.stanza, "modify", "not-allowed", "Invisible Nicknames are forbidden")); |
| 443 return true; | 443 return true; |
| 444 end | 444 end |
| 445 end, 1); | 445 end, 1); |
| 446 | |
| 447 module:hook("muc-occupant-pre-join", function(event) | |
| 448 local nick = jid_resource(event.occupant.nick); | |
| 449 if not resourceprep(nick, true) then -- strict | |
| 450 event.origin.send(st.error_reply(event.stanza, "modify", "jid-malformed", "Nickname must pass strict validation")); | |
| 451 return true; | |
| 452 end | |
| 453 end, 2); | |
| 454 | |
| 455 module:hook("muc-occupant-pre-change", function(event) | |
| 456 local nick = jid_resource(event.dest_occupant.nick); | |
| 457 if not resourceprep(nick, true) then -- strict | |
| 458 event.origin.send(st.error_reply(event.stanza, "modify", "jid-malformed", "Nickname must pass strict validation")); | |
| 459 return true; | |
| 460 end | |
| 461 end, 2); | |
| 446 | 462 |
| 447 function room_mt:handle_first_presence(origin, stanza) | 463 function room_mt:handle_first_presence(origin, stanza) |
| 448 local real_jid = stanza.attr.from; | 464 local real_jid = stanza.attr.from; |
| 449 local dest_jid = stanza.attr.to; | 465 local dest_jid = stanza.attr.to; |
| 450 local bare_jid = jid_bare(real_jid); | 466 local bare_jid = jid_bare(real_jid); |
