Software /
code /
prosody
Comparison
plugins/muc/muc.lib.lua @ 8187:4d83876aac3e
MUC: Reject whitespace-only nicknames (fixes #337)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 21 Jul 2017 00:07:34 +0200 |
parent | 8176:f07cfc9b9b36 |
child | 8191:d43012448c1f |
comparison
equal
deleted
inserted
replaced
8186:becb593ed86d | 8187:4d83876aac3e |
---|---|
433 if current_nick == to then -- simple presence | 433 if current_nick == to then -- simple presence |
434 log("debug", "%s broadcasted presence", current_nick); | 434 log("debug", "%s broadcasted presence", current_nick); |
435 self._occupants[current_nick].sessions[from] = pr; | 435 self._occupants[current_nick].sessions[from] = pr; |
436 self:broadcast_presence(pr, from); | 436 self:broadcast_presence(pr, from); |
437 else -- change nick | 437 else -- change nick |
438 -- a MUC service MUST NOT allow empty or invisible Room Nicknames | |
439 -- (i.e., Room Nicknames that consist only of one or more space characters). | |
440 if not select(3, jid_split(nick)):find("[^ ]") then -- resourceprep turns all whitespace into 0x20 | |
441 module:log("debug", "Rejecting invisible nickname"); | |
442 origin.send(st.error_reply(stanza, "cancel", "not-allowed")); | |
443 return; | |
444 end | |
438 local occupant = self._occupants[current_nick]; | 445 local occupant = self._occupants[current_nick]; |
439 local is_multisession = next(occupant.sessions, next(occupant.sessions)); | 446 local is_multisession = next(occupant.sessions, next(occupant.sessions)); |
440 if self._occupants[to] or is_multisession then | 447 if self._occupants[to] or is_multisession then |
441 log("debug", "%s couldn't change nick", current_nick); | 448 log("debug", "%s couldn't change nick", current_nick); |
442 local reply = st.error_reply(stanza, "cancel", "conflict"):up(); | 449 local reply = st.error_reply(stanza, "cancel", "conflict"):up(); |
465 -- self:handle_to_occupant(origin, st.presence({type='unavailable', from=from, to=to}) | 472 -- self:handle_to_occupant(origin, st.presence({type='unavailable', from=from, to=to}) |
466 -- :tag('status'):text('Replaced by new connection'):up()); -- send unavailable | 473 -- :tag('status'):text('Replaced by new connection'):up()); -- send unavailable |
467 -- self:handle_to_occupant(origin, stanza); -- resend available | 474 -- self:handle_to_occupant(origin, stanza); -- resend available |
468 --end | 475 --end |
469 else -- enter room | 476 else -- enter room |
477 -- a MUC service MUST NOT allow empty or invisible Room Nicknames | |
478 -- (i.e., Room Nicknames that consist only of one or more space characters). | |
479 if not select(3, jid_split(nick)):find("[^ ]") then -- resourceprep turns all whitespace into 0x20 | |
480 module:log("debug", "Rejecting invisible nickname"); | |
481 origin.send(st.error_reply(stanza, "cancel", "not-allowed")); | |
482 return; | |
483 end | |
470 local new_nick = to; | 484 local new_nick = to; |
471 local is_merge; | 485 local is_merge; |
472 if self._occupants[to] then | 486 if self._occupants[to] then |
473 if jid_bare(from) ~= jid_bare(self._occupants[to].jid) then | 487 if jid_bare(from) ~= jid_bare(self._occupants[to].jid) then |
474 new_nick = nil; | 488 new_nick = nil; |