From 4d0d1d74d4f40260a79161163b4b2f7276bce0b0 Mon Sep 17 00:00:00 2001
From: Sebastian Wick <sebastian.wick@redhat.com>
Date: Wed, 25 Feb 2026 04:33:50 +0100
Subject: [PATCH] Improve detection of eavesdrop=true

While in bus-broker, the eavesdrop match must follow the form of
`eavesdrop=[true|false]`, dbus-broker is more forgiving in its parsing
and also accepts `eavesdrop =[true|false]` and other whitespace (\t\r\n)
between `eavesdrop` and `=`. Let's make sure we also find those cases.
---
 flatpak-proxy.c | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)

Index: xdg-dbus-proxy-0.1.2/flatpak-proxy.c
===================================================================
--- xdg-dbus-proxy-0.1.2.orig/flatpak-proxy.c
+++ xdg-dbus-proxy-0.1.2/flatpak-proxy.c
@@ -1791,12 +1791,36 @@ get_arg0_string (Buffer *buffer)
   return name;
 }
 
+/* Matches against any "eavesdrop=", "eavesdrop =", etc. in str */
+static gboolean
+is_eavesdrop (const char *str)
+{
+  const char *e = str;
+
+  while (TRUE)
+    {
+      e = strstr (e, "eavesdrop");
+      if (e == NULL)
+        return FALSE;
+
+      e += strlen ("eavesdrop");
+
+      while (*e == ' '||
+             *e == '\t' ||
+             *e == '\n' ||
+             *e == '\r')
+        e++;
+
+      if (e[0] == '=')
+        return TRUE;
+    }
+}
+
 static gboolean
 validate_arg0_match (FlatpakProxyClient *client, Buffer *buffer)
 {
   GDBusMessage *message = g_dbus_message_new_from_blob (buffer->data, buffer->size, 0, NULL);
   GVariant *body, *arg0;
-  const char *match;
   gboolean res = TRUE;
 
   if (message != NULL &&
@@ -1804,8 +1828,7 @@ validate_arg0_match (FlatpakProxyClient
       (arg0 = g_variant_get_child_value (body, 0)) != NULL &&
       g_variant_is_of_type (arg0, G_VARIANT_TYPE_STRING))
     {
-      match = g_variant_get_string (arg0, NULL);
-      if (strstr (match, "eavesdrop=") != NULL)
+      if (is_eavesdrop (g_variant_get_string (arg0, NULL)))
         res = FALSE;
     }
 
