aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2022-01-10 16:52:13 +0100
committerfiaxh <git@lightrise.org>2022-01-10 17:11:24 +0100
commitf2ef2bcfe7f3e5d1449285c1517df703af1221a4 (patch)
treea196c164a6a98bf1fc1c4f15b5d96077d1453802 /xmpp-vala
parent82a492b33f1232c26db75dbef2d94a800161d466 (diff)
downloaddino-f2ef2bcfe7f3e5d1449285c1517df703af1221a4.tar.gz
dino-f2ef2bcfe7f3e5d1449285c1517df703af1221a4.zip
Only process PEP messages from bare JIDs
Diffstat (limited to 'xmpp-vala')
-rw-r--r--xmpp-vala/src/module/xep/0060_pubsub.vala11
-rw-r--r--xmpp-vala/src/module/xep/0084_user_avatars.vala2
-rw-r--r--xmpp-vala/src/module/xep/0402_bookmarks2.vala2
3 files changed, 12 insertions, 3 deletions
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<string, ItemListenerDelegate> item_listeners = new HashMap<string, ItemListenerDelegate>();
private HashMap<string, RetractListenerDelegate> retract_listeners = new HashMap<string, RetractListenerDelegate>();
+ private ArrayList<string> pep_subset_listeners = new ArrayList<string>();
- 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) {