aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_component.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2022-12-12 07:10:54 +0100
committerKim Alvefur <zash@zash.se>2022-12-12 07:10:54 +0100
commit080d7974bf0c1da8a1c0578d67c3172facc9d719 (patch)
tree838d6904e47ab8681928b37701ff4f1c6e89184a /plugins/mod_component.lua
parentbaff85a52c5fda705e8b3699410c770f015d89ab (diff)
parentc916ce76ee89dca32e7e653dff1ade4732462efc (diff)
downloadprosody-080d7974bf0c1da8a1c0578d67c3172facc9d719.tar.gz
prosody-080d7974bf0c1da8a1c0578d67c3172facc9d719.zip
Merge 0.12->trunk
Diffstat (limited to 'plugins/mod_component.lua')
-rw-r--r--plugins/mod_component.lua29
1 files changed, 13 insertions, 16 deletions
diff --git a/plugins/mod_component.lua b/plugins/mod_component.lua
index f57c4381..c1c29b5e 100644
--- a/plugins/mod_component.lua
+++ b/plugins/mod_component.lua
@@ -17,7 +17,7 @@ local logger = require "util.logger";
local sha1 = require "util.hashes".sha1;
local st = require "util.stanza";
-local jid_split = require "util.jid".split;
+local jid_host = require "util.jid".host;
local new_xmpp_stream = require "util.xmppstream".new;
local uuid_gen = require "util.uuid".generate;
@@ -222,22 +222,19 @@ function stream_callbacks.handlestanza(session, stanza)
end
if not stanza.attr.xmlns or stanza.attr.xmlns == "jabber:client" then
local from = stanza.attr.from;
- if from then
- if session.component_validate_from then
- local _, domain = jid_split(stanza.attr.from);
- if domain ~= session.host then
- -- Return error
- session.log("warn", "Component sent stanza with missing or invalid 'from' address");
- session:close{
- condition = "invalid-from";
- text = "Component tried to send from address <"..tostring(from)
- .."> which is not in domain <"..tostring(session.host)..">";
- };
- return;
- end
+ if session.component_validate_from then
+ if not from or (jid_host(from) ~= session.host) then
+ -- Return error
+ session.log("warn", "Component sent stanza with missing or invalid 'from' address");
+ session:close{
+ condition = "invalid-from";
+ text = "Component tried to send from address <"..(from or "< [missing 'from' attribute] >")
+ .."> which is not in domain <"..tostring(session.host)..">";
+ };
+ return;
end
- else
- stanza.attr.from = session.host; -- COMPAT: Strictly we shouldn't allow this
+ elseif not from then
+ stanza.attr.from = session.host;
end
if not stanza.attr.to then
session.log("warn", "Rejecting stanza with no 'to' address");