From 209b0314a4d2c5c2927c8ce8e7305864d721db1b Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Sun, 23 Dec 2018 15:25:01 +0100 Subject: mod_mam: Only accept valid JIDs in and prefs. (fixes #1275) --- plugins/mod_mam/mamprefsxml.lib.lua | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/plugins/mod_mam/mamprefsxml.lib.lua b/plugins/mod_mam/mamprefsxml.lib.lua index 8eee78d8..c408fbea 100644 --- a/plugins/mod_mam/mamprefsxml.lib.lua +++ b/plugins/mod_mam/mamprefsxml.lib.lua @@ -2,6 +2,7 @@ -- Copyright (C) 2008-2017 Matthew Wild -- Copyright (C) 2008-2017 Waqas Hussain -- Copyright (C) 2011-2017 Kim Alvefur +-- Copyright (C) 2018 Emmanuel Gil Peyrot -- -- This project is MIT/X11 licensed. Please see the -- COPYING file in the source package for more information. @@ -10,6 +11,7 @@ -- local st = require"util.stanza"; +local jid_prep = require"util.jid".prep; local xmlns_mam = "urn:xmpp:mam:2"; local default_attrs = { @@ -42,16 +44,20 @@ local function fromstanza(prefstanza) local always = prefstanza:get_child("always"); if always then for rule in always:childtags("jid") do - local jid = rule:get_text(); - prefs[jid] = true; + local jid = jid_prep(rule:get_text()); + if jid then + prefs[jid] = true; + end end end local never = prefstanza:get_child("never"); if never then for rule in never:childtags("jid") do - local jid = rule:get_text(); - prefs[jid] = false; + local jid = jid_prep(rule:get_text()); + if jid then + prefs[jid] = false; + end end end -- cgit v1.2.3 From 76fa7586ef490a4a6ea87a541ed1a5f09aa1f272 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 23 Dec 2018 15:22:49 +0100 Subject: mod_mam: Add test for JID normalization in prefs (see #1275) --- spec/scansion/mam_prefs_prep.scs | 36 ++++++++++++++++++++++++++++++++++++ spec/scansion/prosody.cfg.lua | 3 ++- 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 spec/scansion/mam_prefs_prep.scs diff --git a/spec/scansion/mam_prefs_prep.scs b/spec/scansion/mam_prefs_prep.scs new file mode 100644 index 00000000..9589ec65 --- /dev/null +++ b/spec/scansion/mam_prefs_prep.scs @@ -0,0 +1,36 @@ +# mod_mam shold apply JIDprep in prefs + +[Client] Romeo + jid: romeo@localhost + password: password + +----- + +Romeo connects + +Romeo sends: + + + + JULIET@MONTAGUE.LIT + + + MONTAGUE@MONTAGUE.LIT + + + + +Romeo receives: + + + + juliet@montague.lit + + + montague@montague.lit + + + + +Romeo disconnects + diff --git a/spec/scansion/prosody.cfg.lua b/spec/scansion/prosody.cfg.lua index 94861449..f95ea31b 100644 --- a/spec/scansion/prosody.cfg.lua +++ b/spec/scansion/prosody.cfg.lua @@ -25,7 +25,7 @@ modules_enabled = { "time"; -- Let others know the time here on this server "ping"; -- Replies to XMPP pings with pongs "register"; -- Allow users to register on this server using a client and change passwords - --"mam"; -- Store messages in an archive and allow users to access it + "mam"; -- Store messages in an archive and allow users to access it -- HTTP modules --"bosh"; -- Enable BOSH clients, aka "Jabber over HTTP" @@ -59,6 +59,7 @@ insecure_open_authentication = "Yes please, I know what I'm doing!" storage = "memory" +mam_smart_enable = true -- For the "sql" backend, you can uncomment *one* of the below to configure: --sql = { driver = "SQLite3", database = "prosody.sqlite" } -- Default. 'database' is the filename. -- cgit v1.2.3