mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-26 05:56:14 +01:00
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
This commit is contained in:
parent
1489955444
commit
1e2579da2c
@ -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)
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user