diff options
author | Kim Alvefur <zash@zash.se> | 2016-11-19 18:28:59 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2016-11-19 18:28:59 +0100 |
commit | 498600dcba7ab38d45ff17bdaba63ea7a999d75c (patch) | |
tree | c010962042421d61e764ce20607ac8c969ccc859 /plugins/mod_mam/mod_mam.lua | |
parent | 338ae79c3153fd333e11c75b87b37e8dfdc2c68f (diff) | |
download | prosody-498600dcba7ab38d45ff17bdaba63ea7a999d75c.tar.gz prosody-498600dcba7ab38d45ff17bdaba63ea7a999d75c.zip |
mod_mam: Filter out spoofed XEP-0359 tags
Diffstat (limited to 'plugins/mod_mam/mod_mam.lua')
-rw-r--r-- | plugins/mod_mam/mod_mam.lua | 12 |
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()); |