# HG changeset patch # User Kim Alvefur # Date 1500588454 -7200 # Node ID 4d83876aac3ecde3aae5bb94795e869bf2fbb8ac # Parent becb593ed86d39e2aba1efe21d2bee0603e1b480 MUC: Reject whitespace-only nicknames (fixes #337) diff -r becb593ed86d -r 4d83876aac3e plugins/muc/muc.lib.lua --- a/plugins/muc/muc.lib.lua Fri Aug 04 18:52:15 2017 +0100 +++ b/plugins/muc/muc.lib.lua Fri Jul 21 00:07:34 2017 +0200 @@ -435,6 +435,13 @@ self._occupants[current_nick].sessions[from] = pr; self:broadcast_presence(pr, from); else -- change nick + -- a MUC service MUST NOT allow empty or invisible Room Nicknames + -- (i.e., Room Nicknames that consist only of one or more space characters). + if not select(3, jid_split(nick)):find("[^ ]") then -- resourceprep turns all whitespace into 0x20 + module:log("debug", "Rejecting invisible nickname"); + origin.send(st.error_reply(stanza, "cancel", "not-allowed")); + return; + end local occupant = self._occupants[current_nick]; local is_multisession = next(occupant.sessions, next(occupant.sessions)); if self._occupants[to] or is_multisession then @@ -467,6 +474,13 @@ -- self:handle_to_occupant(origin, stanza); -- resend available --end else -- enter room + -- a MUC service MUST NOT allow empty or invisible Room Nicknames + -- (i.e., Room Nicknames that consist only of one or more space characters). + if not select(3, jid_split(nick)):find("[^ ]") then -- resourceprep turns all whitespace into 0x20 + module:log("debug", "Rejecting invisible nickname"); + origin.send(st.error_reply(stanza, "cancel", "not-allowed")); + return; + end local new_nick = to; local is_merge; if self._occupants[to] then