aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_mam
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2016-11-19 18:28:59 +0100
committerKim Alvefur <zash@zash.se>2016-11-19 18:28:59 +0100
commit99ad7ae5e6c1b2ac930bc0ec20cf028051fd9553 (patch)
treec010962042421d61e764ce20607ac8c969ccc859 /plugins/mod_mam
parentdbd0d9fea7c5ca61e2acceb91ef774ade00d6a42 (diff)
downloadprosody-99ad7ae5e6c1b2ac930bc0ec20cf028051fd9553.tar.gz
prosody-99ad7ae5e6c1b2ac930bc0ec20cf028051fd9553.zip
mod_mam: Filter out spoofed XEP-0359 tags
Diffstat (limited to 'plugins/mod_mam')
-rw-r--r--plugins/mod_mam/mod_mam.lua12
1 files changed, 12 insertions, 0 deletions
diff --git a/plugins/mod_mam/mod_mam.lua b/plugins/mod_mam/mod_mam.lua
index 2606f861..cb7613b8 100644
--- a/plugins/mod_mam/mod_mam.lua
+++ b/plugins/mod_mam/mod_mam.lua
@@ -16,6 +16,7 @@ local prefs_to_stanza = module:require"mamprefsxml".tostanza;
local prefs_from_stanza = module:require"mamprefsxml".fromstanza;
local jid_bare = require "util.jid".bare;
local jid_split = require "util.jid".split;
+local jid_prepped_split = require "util.jid".prepped_split;
local dataform = require "util.dataforms".new;
local host = module.host;
@@ -238,6 +239,17 @@ local function message_handler(event, c2s)
-- And who are they chatting with?
local with = jid_bare(c2s and orig_to or orig_from);
+ -- Filter out <stanza-id> that claim to be from us
+ stanza:maptags(function (tag)
+ if tag.name == "stanza-id" and tag.attr.xmlns == "urn:xmpp:sid:0" then
+ local by_user, by_host, res = prepped_split(tag.attr.by);
+ if not res and by_host == module.host and by_user == store_user then
+ return nil;
+ end
+ end
+ return tag;
+ end);
+
-- We store chat messages or normal messages that have a body
if not(orig_type == "chat" or (orig_type == "normal" and stanza:get_child("body")) ) then
log("debug", "Not archiving stanza: %s (type)", stanza:top_tag());