aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/muc
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2019-11-01 22:08:38 +0100
committerKim Alvefur <zash@zash.se>2019-11-01 22:08:38 +0100
commit8de5e91be6f1c6e5fb1009d4a90dfea73b17cb48 (patch)
tree4f4c8d6da6d7c1b091cc729f68f122a2d234291c /plugins/muc
parent03adb505558555cd2449bea0ae83c0a89c82a399 (diff)
downloadprosody-8de5e91be6f1c6e5fb1009d4a90dfea73b17cb48.tar.gz
prosody-8de5e91be6f1c6e5fb1009d4a90dfea73b17cb48.zip
MUC: Strictly validate room JID on creation
This should prevent any MUCs with invalid JID (according to current normalization routine)
Diffstat (limited to 'plugins/muc')
-rw-r--r--plugins/muc/mod_muc.lua8
1 files changed, 8 insertions, 0 deletions
diff --git a/plugins/muc/mod_muc.lua b/plugins/muc/mod_muc.lua
index e55bd6a2..166249cc 100644
--- a/plugins/muc/mod_muc.lua
+++ b/plugins/muc/mod_muc.lua
@@ -93,6 +93,7 @@ room_mt.get_valid_broadcast_roles = presence_broadcast.get_valid_broadcast_roles
local jid_split = require "util.jid".split;
+local jid_prep = require "util.jid".prep;
local jid_bare = require "util.jid".bare;
local st = require "util.stanza";
local cache = require "util.cache";
@@ -273,6 +274,9 @@ local function set_room_defaults(room, lang)
end
function create_room(room_jid, config)
+ if jid_bare(room_jid) ~= room_jid or not jid_prep(room_jid, true) then
+ return nil, "invalid-jid";
+ end
local exists = get_room_from_jid(room_jid);
if exists then
return nil, "room-exists";
@@ -460,6 +464,10 @@ for event_name, method in pairs {
if room == nil then
-- Watch presence to create rooms
+ if not jid_prep(room_jid, true) then
+ origin.send(st.error_reply(stanza, "modify", "jid-malformed"));
+ return true;
+ end
if stanza.attr.type == nil and stanza.name == "presence" and stanza:get_child("x", "http://jabber.org/protocol/muc") then
room = muclib.new_room(room_jid);
return room:handle_first_presence(origin, stanza);