Diff

plugins/mod_pubsub/pubsub.lib.lua @ 8940:365b16109d95

mod_pubsub: Apply normalization to JIDs retrieved from attributes
author Kim Alvefur <zash@zash.se>
date Tue, 26 Jun 2018 20:28:53 +0200
parent 8939:849c4683eaa0
child 8953:19cbe80df9c8
line wrap: on
line diff
--- a/plugins/mod_pubsub/pubsub.lib.lua	Tue Jun 26 20:27:41 2018 +0200
+++ b/plugins/mod_pubsub/pubsub.lib.lua	Tue Jun 26 20:28:53 2018 +0200
@@ -1,6 +1,7 @@
 local t_unpack = table.unpack or unpack; -- luacheck: ignore 113
 local time_now = os.time;
 
+local jid_prep = require "util.jid".prep;
 local set = require "util.set";
 local st = require "util.stanza";
 local it = require "util.iterators";
@@ -259,6 +260,7 @@
 
 function handlers.set_subscribe(origin, stanza, subscribe, service)
 	local node, jid = subscribe.attr.node, subscribe.attr.jid;
+	jid = jid_prep(jid);
 	if not (node and jid) then
 		origin.send(pubsub_error_reply(stanza, jid and "nodeid-required" or "invalid-jid"));
 		return true;
@@ -288,6 +290,7 @@
 
 function handlers.set_unsubscribe(origin, stanza, unsubscribe, service)
 	local node, jid = unsubscribe.attr.node, unsubscribe.attr.jid;
+	jid = jid_prep(jid);
 	if not (node and jid) then
 		origin.send(pubsub_error_reply(stanza, jid and "nodeid-required" or "invalid-jid"));
 		return true;
@@ -504,6 +507,7 @@
 		local jid = affiliation_tag.attr.jid;
 		local affiliation = affiliation_tag.attr.affiliation;
 
+		jid = jid_prep(jid);
 		if affiliation == "none" then affiliation = nil; end
 
 		local ok, err = service:set_affiliation(node, stanza.attr.from, jid, affiliation);