diff options
author | Matthew Wild <mwild1@gmail.com> | 2010-05-21 19:20:21 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2010-05-21 19:20:21 +0100 |
commit | 057b593a68d47869e23834321e65a2af5b0f46fc (patch) | |
tree | 4340e1daf7f12a0dbbe0f084cb638233e35bfe90 /plugins/mod_privacy.lua | |
parent | 7398bee580883ce652fa3de579daa483caac5bfa (diff) | |
download | prosody-057b593a68d47869e23834321e65a2af5b0f46fc.tar.gz prosody-057b593a68d47869e23834321e65a2af5b0f46fc.zip |
mod_privacy: Fix several possible tracebacks when either the contact is a host JID, or the contact isn't in your roster and you have roster group/subscription rules in place
Diffstat (limited to 'plugins/mod_privacy.lua')
-rw-r--r-- | plugins/mod_privacy.lua | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/plugins/mod_privacy.lua b/plugins/mod_privacy.lua index 5a25f9a5..3e9dbe49 100644 --- a/plugins/mod_privacy.lua +++ b/plugins/mod_privacy.lua @@ -13,7 +13,7 @@ local datamanager = require "util.datamanager"; local bare_sessions, full_sessions = bare_sessions, full_sessions; local util_Jid = require "util.jid"; local jid_bare = util_Jid.bare; -local jid_split = util_Jid.split; +local jid_split, jid_join = util_Jid.split, util_Jid.join; local load_roster = require "core.rostermanager".load_roster; local to_number = tonumber; @@ -360,17 +360,22 @@ function checkIfNeedToBeBlocked(e, session) block = (item.action == "deny"); elseif item.type == "group" then local roster = load_roster(session.username, session.host); - local groups = roster[evilJid.node .. "@" .. evilJid.host].groups; - for group in pairs(groups) do - if group == item.value then - apply = true; - block = (item.action == "deny"); - break; + local roster_entry = roster[jid_join(evilJid.node, evilJid.host)]; + if roster_entry then + local groups = roster_entry.groups; + for group in pairs(groups) do + if group == item.value then + apply = true; + block = (item.action == "deny"); + break; + end end end - elseif item.type == "subscription" and evilJid.node ~= nil and evilJid.host ~= nil then -- we need a valid bare evil jid + elseif item.type == "subscription" then -- we need a valid bare evil jid local roster = load_roster(session.username, session.host); - if roster[evilJid.node .. "@" .. evilJid.host].subscription == item.value then + local roster_entry = roster[jid_join(evilJid.node, evilJid.host)]; + if (not(roster_entry) and item.value == "none") + or (roster_entry and roster_entry.subscription == item.value) then apply = true; block = (item.action == "deny"); end |