diff options
author | Allison Ryan Lortie <desrt@desrt.ca> | 2016-04-12 11:06:11 -0400 |
---|---|---|
committer | Allison Ryan Lortie <desrt@desrt.ca> | 2016-04-25 09:19:23 +0200 |
commit | 3301b852a20b3d1f75592d03dd4038d3ea2fed7c (patch) | |
tree | e2b1f556442ef189a61eda68413ed80170d29620 | |
parent | bd0911afda3e087b80c93713a9a9866267857583 (diff) | |
download | glib-3301b852a20b3d1f75592d03dd4038d3ea2fed7c.tar.gz |
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
-rw-r--r-- | gio/gdesktopappinfo.c | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/gio/gdesktopappinfo.c b/gio/gdesktopappinfo.c index ac9c7eb61..d65288d2d 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 * |