From 1f641135e23e32de3165224c77a7ba7206ea2b99 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Mon, 29 Aug 2016 08:55:28 +0200 Subject: [PATCH] Extra checks when parsing file. --- source/dialogs/drun.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/source/dialogs/drun.c b/source/dialogs/drun.c index 7dd1a154..cb315b89 100644 --- a/source/dialogs/drun.c +++ b/source/dialogs/drun.c @@ -171,6 +171,17 @@ static void read_desktop_file ( DRunModePrivateData *pd, const char *root, char g_free ( id ); return; } + // Skip non Application entries. + if ( g_key_file_has_key ( kf, "Desktop Entry", "Type", NULL )){ + gchar *key = g_key_file_get_string ( kf, "Desktop Entry", "Type", NULL ); + if ( g_strcmp0(key, "Application")){ + g_free(key); + g_key_file_free ( kf ); + g_free ( path ); + g_free ( id ); + return; + } + } // Skip hidden entries. if ( g_key_file_has_key ( kf, "Desktop Entry", "Hidden", NULL ) ) { if ( g_key_file_get_boolean ( kf, "Desktop Entry", "Hidden", NULL ) ) { @@ -197,6 +208,14 @@ static void read_desktop_file ( DRunModePrivateData *pd, const char *root, char g_free ( id ); return; } + // We need Exec, don't support DBusActivatable + if ( !g_key_file_has_key ( kf, "Desktop Entry", "Exec", NULL ) ) { + fprintf(stderr, "DesktopFile has no Exec option, DBusActivatable is not supported: '%s'\n", path); + g_key_file_free ( kf ); + g_free ( path ); + g_free ( id ); + return; + } if ( g_key_file_has_key ( kf, "Desktop Entry", "Exec", NULL ) ) { size_t nl = ( ( pd->cmd_list_length ) + 1 ); pd->entry_list = g_realloc ( pd->entry_list, nl * sizeof ( *( pd->entry_list ) ) ); @@ -310,7 +329,6 @@ static void get_apps_history ( DRunModePrivateData *pd ) char **st = g_strsplit ( retv[index], ":::", 2 ); if ( st && st[0] && st[1] ) { gchar *name = g_path_get_basename ( st[1] ); - printf ( ": %s\n", st[0] ); read_desktop_file ( pd, st[0], g_strdup ( st[1] ), name ); g_free ( name ); }