[glib] GDesktopAppInfo: support bus activation with '-'
- From: Allison Ryan Lortie <desrt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] GDesktopAppInfo: support bus activation with '-'
- Date: Mon, 25 Apr 2016 07:30:11 +0000 (UTC)
commit 3301b852a20b3d1f75592d03dd4038d3ea2fed7c
Author: Allison Ryan Lortie <desrt desrt ca>
Date: Tue Apr 12 11:06:11 2016 -0400
GDesktopAppInfo: support bus activation with '-'
GApplication has accepted any valid bus name as an application ID since
before the time of D-Bus activation. This includes bus names with '-'.
Several applications have even attempted support bus activation with
these names, going as far as installing D-Bus service files, without
realising that they are silently falling back to fork()/exec() on
account of the name containing a dash.
The reason for the problem is that D-Bus object paths cannot contain
dashes. We solved this problem privately in an unspecified way inside
of GApplication but substituting '_' in this case, but never made this
part of the Desktop Entry Specification.
The fact that these apps with '-' in the desktop file names aren't
actually using D-Bus activation is beside the point: their intent here
was clear. Let's avoid forcing them to rename their desktop files again
by simply accepting '-' in desktop file names and munging the path in
the way that GApplication did so historically.
The new path escaping code here has been copied more or less verbatim
from GApplication's own code for the same purpose, with only the removal
of one irrelevant part.
An update to the desktop entry specification will follow.
https://bugzilla.gnome.org/show_bug.cgi?id=764754
gio/gdesktopappinfo.c | 28 ++++++++++++----------------
1 files changed, 12 insertions(+), 16 deletions(-)
---
diff --git a/gio/gdesktopappinfo.c b/gio/gdesktopappinfo.c
index ac9c7eb..d65288d 100644
--- a/gio/gdesktopappinfo.c
+++ b/gio/gdesktopappinfo.c
@@ -1794,7 +1794,7 @@ g_desktop_app_info_load_from_keyfile (GDesktopAppInfo *info,
{
*last_dot = '\0';
- if (g_dbus_is_interface_name (basename))
+ if (g_dbus_is_name (basename) && basename[0] != ':')
info->app_id = g_strdup (basename);
}
@@ -2785,25 +2785,21 @@ g_desktop_app_info_launch_uris_with_spawn (GDesktopAppInfo *info,
}
static gchar *
-object_path_from_appid (const gchar *app_id)
+object_path_from_appid (const gchar *appid)
{
- gchar *path;
- gint i, n;
+ gchar *appid_path, *iter;
- n = strlen (app_id);
- path = g_malloc (n + 2);
-
- path[0] = '/';
-
- for (i = 0; i < n; i++)
- if (app_id[i] != '.')
- path[i + 1] = app_id[i];
- else
- path[i + 1] = '/';
+ appid_path = g_strconcat ("/", appid, NULL);
+ for (iter = appid_path; *iter; iter++)
+ {
+ if (*iter == '.')
+ *iter = '/';
- path[i + 1] = '\0';
+ if (*iter == '-')
+ *iter = '_';
+ }
- return path;
+ return appid_path;
}
static GVariant *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]