diff options
author | Richard Hughes <richard@hughsie.com> | 2016-07-15 09:50:21 +0100 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2016-07-15 09:51:32 +0100 |
commit | 753a5e78137d826bcfe2d55c16da184f37b024b5 (patch) | |
tree | 8aff0d8c39827a23413ca99c2c38b4de5e90703d /libappstream-glib/as-app-desktop.c | |
parent | c7b0dae733604990fc96ccb94aa034822f28cea4 (diff) | |
download | appstream-glib-753a5e78137d826bcfe2d55c16da184f37b024b5.tar.gz |
Do not save the 'X-' prefixed keys to the AppStream metadata
Continue to load them at runtime from installed desktop files.
Diffstat (limited to 'libappstream-glib/as-app-desktop.c')
-rw-r--r-- | libappstream-glib/as-app-desktop.c | 42 |
1 files changed, 33 insertions, 9 deletions
diff --git a/libappstream-glib/as-app-desktop.c b/libappstream-glib/as-app-desktop.c index 339445e..c668fab 100644 --- a/libappstream-glib/as-app-desktop.c +++ b/libappstream-glib/as-app-desktop.c @@ -108,6 +108,36 @@ _as_utils_is_stock_icon_name_fallback (const gchar *name) return FALSE; } +static void +as_app_parse_file_metadata (AsApp *app, GKeyFile *kf, const gchar *key) +{ + guint i; + g_autofree gchar *value = NULL; + const gchar *blacklist[] = { + "X-AppInstall-*", + "X-Desktop-File-Install-Version", + "X-Geoclue-Reason*", + "X-GNOME-Bugzilla-*", + "X-GNOME-FullName*", + "X-GNOME-Gettext-Domain", + "X-GNOME-UsesNotifications", + NULL }; + + if (!g_str_has_prefix (key, "X-")) + return; + + /* anything blacklisted */ + for (i = 0; blacklist[i] != NULL; i++) { + if (fnmatch (blacklist[i], key, 0) == 0) + return; + } + value = g_key_file_get_string (kf, + G_KEY_FILE_DESKTOP_GROUP, + key, + NULL); + as_app_add_metadata (app, key, value); +} + static gboolean as_app_parse_file_key (AsApp *app, GKeyFile *kf, @@ -347,15 +377,9 @@ as_app_parse_file_key (AsApp *app, as_app_add_veto (app, "X-AppStream-Ignore"); } - /* Add any external attribute as metadata to the application */ - if (g_str_has_prefix (key, "X-")) { - g_autofree char *value = NULL; - value = g_key_file_get_string (kf, - G_KEY_FILE_DESKTOP_GROUP, - key, - NULL); - as_app_add_metadata (app, key, value); - } + /* add any external attribute as metadata to the application */ + if (flags & AS_APP_PARSE_FLAG_ADD_ALL_METADATA) + as_app_parse_file_metadata (app, kf, key); return TRUE; } |