MUC: Prep given JID when changing affiliation.

Fri, 02 Oct 2009 17:56:24 +0500

author
Waqas Hussain <waqas20@gmail.com>
date
Fri, 02 Oct 2009 17:56:24 +0500
changeset 1862
115f274dd17f
parent 1861
e9500c4994f3
child 1865
388b125b784a

MUC: Prep given JID when changing affiliation.

plugins/muc/muc.lib.lua file | annotate | diff | comparison | revisions
--- a/plugins/muc/muc.lib.lua	Fri Oct 02 17:51:53 2009 +0500
+++ b/plugins/muc/muc.lib.lua	Fri Oct 02 17:56:24 2009 +0500
@@ -11,6 +11,7 @@
 
 local jid_split = require "util.jid".split;
 local jid_bare = require "util.jid".bare;
+local jid_prep = require "util.jid".prep;
 local st = require "util.stanza";
 local log = require "util.logger".init("mod_muc");
 local multitable_new = require "util.multitable".new;
@@ -412,6 +413,13 @@
 			if item and item.name == "item" then
 				if type == "set" then
 					local callback = function() origin.send(st.reply(stanza)); end
+					if item.attr.jid then -- Validate provided JID
+						item.attr.jid = jid_prep(item.attr.jid);
+						if not item.attr.jid then
+							origin.send(st.error_reply(stanza, "modify", "jid-malformed"));
+							return;
+						end
+					end
 					if not item.attr.jid and item.attr.nick then -- COMPAT Workaround for Miranda sending 'nick' instead of 'jid' when changing affiliation
 						local occupant = self._occupants[self.jid.."/"..item.attr.nick];
 						if occupant then item.attr.jid = occupant.jid; end

mercurial