Software /
code /
prosody
Changeset
6186:85f7cd91dc31
plugins/muc/muc.lib: Smarter validation in set_affiliation
author | daurnimator <quae@daurnimator.com> |
---|---|
date | Fri, 28 Mar 2014 14:15:18 -0400 |
parents | 6185:d4a8840e72f9 |
children | 6187:c0b4b5d41e55 |
files | plugins/muc/muc.lib.lua |
diffstat | 1 files changed, 14 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/muc/muc.lib.lua Fri Mar 28 13:34:46 2014 -0400 +++ b/plugins/muc/muc.lib.lua Fri Mar 28 14:15:18 2014 -0400 @@ -1311,12 +1311,24 @@ if not result and self._affiliations[host] == "outcast" then result = "outcast"; end -- host banned return result; end + +local valid_affiliations = { + outcast = true; + none = true; + member = true; + admin = true; + owner = true; +}; function room_mt:set_affiliation(actor, jid, affiliation, reason) + if not actor then return nil, "modify", "not-acceptable"; end; + jid = jid_bare(jid); - if affiliation == "none" then affiliation = nil; end - if affiliation and affiliation ~= "outcast" and affiliation ~= "owner" and affiliation ~= "admin" and affiliation ~= "member" then + + if valid_affiliations[affiliation or "none"] == nil then return nil, "modify", "not-acceptable"; end + affiliation = affiliation ~= "none" and affiliation or nil; -- coerces `affiliation == false` to `nil` + if actor ~= true then local actor_affiliation = self:get_affiliation(actor); local target_affiliation = self:get_affiliation(jid);