Software /
code /
prosody
Changeset
7845:eeb22f912577
mod_mam: Filter out spoofed XEP-0359 tags
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 19 Nov 2016 18:28:59 +0100 |
parents | 7844:316f5166eedb |
children | 7846:22275bc5744a |
files | plugins/mod_mam/mod_mam.lua |
diffstat | 1 files changed, 12 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_mam/mod_mam.lua Sat Nov 19 18:28:28 2016 +0100 +++ b/plugins/mod_mam/mod_mam.lua Sat Nov 19 18:28:59 2016 +0100 @@ -16,6 +16,7 @@ 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 @@ -- 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());