Comparison

plugins/mod_roster.lua @ 12101:7cd94469d15f

mod_roster: Improve readability of bare-JID check Silences luacheck too All we care about is that it is a bare JID, not a full JID with a resource, since those are forbidden in rosters.
author Kim Alvefur <zash@zash.se>
date Wed, 22 Dec 2021 18:07:44 +0100
parent 12100:0b14b541fd27
child 12977:74b9e05af71e
comparison
equal deleted inserted replaced
12100:0b14b541fd27 12101:7cd94469d15f
8 8
9 9
10 local st = require "util.stanza" 10 local st = require "util.stanza"
11 11
12 local jid_split = require "util.jid".split; 12 local jid_split = require "util.jid".split;
13 local jid_resource = require "util.jid".resource;
13 local jid_prep = require "util.jid".prep; 14 local jid_prep = require "util.jid".prep;
14 local tonumber = tonumber; 15 local tonumber = tonumber;
15 local pairs = pairs; 16 local pairs = pairs;
16 17
17 local rm_load_roster = require "core.rostermanager".load_roster; 18 local rm_load_roster = require "core.rostermanager".load_roster;
64 if #query.tags == 1 and query.tags[1].name == "item" 65 if #query.tags == 1 and query.tags[1].name == "item"
65 and query.tags[1].attr.xmlns == "jabber:iq:roster" and query.tags[1].attr.jid then 66 and query.tags[1].attr.xmlns == "jabber:iq:roster" and query.tags[1].attr.jid then
66 local item = query.tags[1]; 67 local item = query.tags[1];
67 local from_node, from_host = jid_split(stanza.attr.from); 68 local from_node, from_host = jid_split(stanza.attr.from);
68 local jid = jid_prep(item.attr.jid); 69 local jid = jid_prep(item.attr.jid);
69 local node, host, resource = jid_split(jid); 70 if jid and not jid_resource(jid) then
70 if not resource and host then
71 if jid ~= from_node.."@"..from_host then 71 if jid ~= from_node.."@"..from_host then
72 if item.attr.subscription == "remove" then 72 if item.attr.subscription == "remove" then
73 local roster = session.roster; 73 local roster = session.roster;
74 local r_item = roster[jid]; 74 local r_item = roster[jid];
75 if r_item then 75 if r_item then