summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Müllner <fmuellner@gnome.org>2018-04-23 19:50:45 +0200
committerFlorian Müllner <fmuellner@gnome.org>2018-04-24 13:11:00 +0200
commit1e2579da2c115f09ab36015c6a02fb3e767e8d68 (patch)
treeae4c4788e51a8b7035dd9edb44ff9065267dddab
parent1489955444ce171a31c7c73d6bd37cd9e6d926ea (diff)
downloadglib-1e2579da2c115f09ab36015c6a02fb3e767e8d68.tar.gz
gdesktopappinfo: Filter out some binary names in search
The executable name can be a useful bit of information to match on in searches where it differs from the name (for example because the latter is localised), but will produce surprising results where the real appli- cation is executed by a shared binary (for example interpretors like gjs or python, or sandboxes like flatpak). Address this by adding a blacklist of binary names that are ignored in search. https://bugzilla.gnome.org/show_bug.cgi?id=795488
-rw-r--r--gio/gdesktopappinfo.c20
-rw-r--r--gio/tests/desktop-app-info.c5
2 files changed, 25 insertions, 0 deletions
diff --git a/gio/gdesktopappinfo.c b/gio/gdesktopappinfo.c
index 869bb8feb..6844ff330 100644
--- a/gio/gdesktopappinfo.c
+++ b/gio/gdesktopappinfo.c
@@ -387,6 +387,22 @@ const gchar desktop_key_match_category[N_DESKTOP_KEYS] = {
[DESKTOP_KEY_Comment] = 6
};
+/* Common prefix commands to ignore from Exec= lines */
+const char * const exec_key_match_blacklist[] = {
+ "bash",
+ "env",
+ "flatpak",
+ "gjs",
+ "pkexec",
+ "python",
+ "python2",
+ "python3",
+ "sh",
+ "wine",
+ "wine64",
+ NULL
+};
+
static gchar *
desktop_key_get_name (guint key_id)
{
@@ -1089,6 +1105,10 @@ desktop_file_dir_unindexed_setup_search (DesktopFileDir *dir)
/* Skip the pathname, if any */
if ((slash = strrchr (raw, '/')))
value = slash + 1;
+
+ /* Don't match on blacklisted binaries like interpreters */
+ if (g_strv_contains (exec_key_match_blacklist, value))
+ value = NULL;
}
if (value)
diff --git a/gio/tests/desktop-app-info.c b/gio/tests/desktop-app-info.c
index 738b78cef..d425eb9e5 100644
--- a/gio/tests/desktop-app-info.c
+++ b/gio/tests/desktop-app-info.c
@@ -667,6 +667,11 @@ test_search (void)
assert_search ("image viewer", "", FALSE, TRUE, NULL, NULL);
assert_search ("image viewer", "", TRUE, TRUE, NULL, NULL);
+ /* There're flatpak apps installed as well - they should *not* match
+ * the "flatpak" command in the Exec= line though.
+ */
+ assert_search ("flatpak", "", TRUE, FALSE, NULL, NULL);
+
/* Obvious multi-word search */
assert_search ("gno hel", "yelp.desktop\n", TRUE, TRUE, NULL, NULL);