From f2ef2bcfe7f3e5d1449285c1517df703af1221a4 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Mon, 10 Jan 2022 16:52:13 +0100 Subject: Only process PEP messages from bare JIDs --- xmpp-vala/src/module/xep/0060_pubsub.vala | 11 ++++++++++- xmpp-vala/src/module/xep/0084_user_avatars.vala | 2 +- xmpp-vala/src/module/xep/0402_bookmarks2.vala | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) (limited to 'xmpp-vala/src') diff --git a/xmpp-vala/src/module/xep/0060_pubsub.vala b/xmpp-vala/src/module/xep/0060_pubsub.vala index c8472576..02e35394 100644 --- a/xmpp-vala/src/module/xep/0060_pubsub.vala +++ b/xmpp-vala/src/module/xep/0060_pubsub.vala @@ -16,8 +16,9 @@ namespace Xmpp.Xep.Pubsub { private HashMap item_listeners = new HashMap(); private HashMap retract_listeners = new HashMap(); + private ArrayList pep_subset_listeners = new ArrayList(); - public void add_filtered_notification(XmppStream stream, string node, + public void add_filtered_notification(XmppStream stream, string node, bool pep_subset, owned ItemListenerDelegate.ResultFunc? item_listener, owned RetractListenerDelegate.ResultFunc? retract_listener) { stream.get_module(ServiceDiscovery.Module.IDENTITY).add_feature_notify(stream, node); @@ -27,6 +28,9 @@ namespace Xmpp.Xep.Pubsub { if (retract_listener != null) { retract_listeners[node] = new RetractListenerDelegate((owned)retract_listener); } + if (pep_subset) { + pep_subset_listeners.add(node); + } } public void remove_filtered_notification(XmppStream stream, string node) { @@ -166,6 +170,11 @@ namespace Xmpp.Xep.Pubsub { if (items_node == null) return; string node = items_node.get_attribute("node", NS_URI_EVENT); + if (!message.from.is_bare() && pep_subset_listeners.contains(node)) { + warning("Got a PEP message from a full JID (%s), ignoring:\n%s", message.from.to_string(), message.stanza.to_string()); + return; + } + StanzaNode? item_node = items_node.get_subnode("item", NS_URI_EVENT); if (item_node != null) { string id = item_node.get_attribute("id", NS_URI_EVENT); diff --git a/xmpp-vala/src/module/xep/0084_user_avatars.vala b/xmpp-vala/src/module/xep/0084_user_avatars.vala index 4f3b6c4f..f3cd4060 100644 --- a/xmpp-vala/src/module/xep/0084_user_avatars.vala +++ b/xmpp-vala/src/module/xep/0084_user_avatars.vala @@ -43,7 +43,7 @@ namespace Xmpp.Xep.UserAvatars { public signal void received_avatar_hash(XmppStream stream, Jid jid, string id); public override void attach(XmppStream stream) { - stream.get_module(Pubsub.Module.IDENTITY).add_filtered_notification(stream, NS_URI_METADATA, on_pupsub_event, null); + stream.get_module(Pubsub.Module.IDENTITY).add_filtered_notification(stream, NS_URI_METADATA, true, on_pupsub_event, null); } public override void detach(XmppStream stream) { diff --git a/xmpp-vala/src/module/xep/0402_bookmarks2.vala b/xmpp-vala/src/module/xep/0402_bookmarks2.vala index 5641769a..9572cc63 100644 --- a/xmpp-vala/src/module/xep/0402_bookmarks2.vala +++ b/xmpp-vala/src/module/xep/0402_bookmarks2.vala @@ -98,7 +98,7 @@ public class Module : BookmarksProvider, XmppStreamModule { } public override void attach(XmppStream stream) { - stream.get_module(Pubsub.Module.IDENTITY).add_filtered_notification(stream, NS_URI, on_pupsub_item, on_pupsub_retract); + stream.get_module(Pubsub.Module.IDENTITY).add_filtered_notification(stream, NS_URI, true, on_pupsub_item, on_pupsub_retract); } public override void detach(XmppStream stream) { -- cgit v1.2.3-70-g09d2