summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2016-07-15 09:50:21 +0100
committerRichard Hughes <richard@hughsie.com>2016-07-15 09:51:32 +0100
commit753a5e78137d826bcfe2d55c16da184f37b024b5 (patch)
tree8aff0d8c39827a23413ca99c2c38b4de5e90703d
parentc7b0dae733604990fc96ccb94aa034822f28cea4 (diff)
downloadappstream-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.
-rw-r--r--libappstream-glib/as-app-desktop.c42
-rw-r--r--libappstream-glib/as-app.h2
-rw-r--r--libappstream-glib/as-store.c3
3 files changed, 38 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;
}
diff --git a/libappstream-glib/as-app.h b/libappstream-glib/as-app.h
index 8b10e55..f027924 100644
--- a/libappstream-glib/as-app.h
+++ b/libappstream-glib/as-app.h
@@ -65,6 +65,7 @@ struct _AsAppClass
* @AS_APP_PARSE_FLAG_APPEND_DATA: Append new data rather than replacing
* @AS_APP_PARSE_FLAG_ALLOW_VETO: Do not return errors for vetoed apps
* @AS_APP_PARSE_FLAG_USE_FALLBACKS: Fall back to suboptimal data where required
+ * @AS_APP_PARSE_FLAG_ADD_ALL_METADATA: Add all extra metadata from the source file
*
* The flags to use when parsing resources.
**/
@@ -76,6 +77,7 @@ typedef enum {
AS_APP_PARSE_FLAG_APPEND_DATA = 8, /* Since: 0.1.8 */
AS_APP_PARSE_FLAG_ALLOW_VETO = 16, /* Since: 0.2.5 */
AS_APP_PARSE_FLAG_USE_FALLBACKS = 32, /* Since: 0.4.1 */
+ AS_APP_PARSE_FLAG_ADD_ALL_METADATA = 64, /* Since: 0.5.18 */
/*< private >*/
AS_APP_PARSE_FLAG_LAST,
} AsAppParseFlags;
diff --git a/libappstream-glib/as-store.c b/libappstream-glib/as-store.c
index 6a38f7d..a92823a 100644
--- a/libappstream-glib/as-store.c
+++ b/libappstream-glib/as-store.c
@@ -2330,6 +2330,9 @@ as_store_load_installed (AsStore *store,
/* emit once when finished */
tok = as_store_changed_inhibit (store);
+ /* always load all the .desktop 'X-' metadata */
+ parse_flags |= AS_APP_PARSE_FLAG_ADD_ALL_METADATA;
+
/* relax the checks when parsing */
if (flags & AS_STORE_LOAD_FLAG_ALLOW_VETO)
parse_flags |= AS_APP_PARSE_FLAG_ALLOW_VETO;