Commit 1e2579da authored by Florian Müllner's avatar Florian Müllner

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.
parent 14899554
Pipeline #9589 failed with stage
in 2 minutes and 18 seconds
......@@ -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[] = {
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)
......@@ -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);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment