diff options
author | Richard Hughes <richard@hughsie.com> | 2017-04-03 20:04:57 +0100 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2017-04-03 20:04:57 +0100 |
commit | ec560da75f06d86b51cc8a83bb6cfca13ef4b43d (patch) | |
tree | face8e38febd778d2314ca4b15a91e3c4048deb8 | |
parent | fe3b9c00f4ea649874cab0a640d9d10654aec6f5 (diff) | |
download | appstream-glib-ec560da75f06d86b51cc8a83bb6cfca13ef4b43d.tar.gz |
Validate kudos in AppData and AppStream files
Fixes https://github.com/hughsie/appstream-glib/issues/162
-rw-r--r-- | libappstream-glib/as-app-validate.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/libappstream-glib/as-app-validate.c b/libappstream-glib/as-app-validate.c index 05959ca..f70496d 100644 --- a/libappstream-glib/as-app-validate.c +++ b/libappstream-glib/as-app-validate.c @@ -879,6 +879,29 @@ as_app_validate_release (AsApp *app, } static gboolean +as_app_validate_kudos (AsApp *app, AsAppValidateHelper *helper, GError **error) +{ + GPtrArray *kudos = as_app_get_kudos (app); + for (guint i = 0; i < kudos->len; i++) { + const gchar *kudo = g_ptr_array_index (kudos, i); + const gchar *valid[] = { "AppMenu", + "HiDpiIcon", + "HighContrast", + "ModernToolkit", + "Notifications", + "SearchProvider", + "UserDocs", + NULL }; + if (!g_strv_contains (valid, kudo)) { + ai_app_validate_add (helper, + AS_PROBLEM_KIND_ATTRIBUTE_INVALID, + "<kudo> is invalid [%s]", kudo); + } + } + return TRUE; +} + +static gboolean as_app_validate_releases (AsApp *app, AsAppValidateHelper *helper, GError **error) { GPtrArray *releases; @@ -1438,6 +1461,10 @@ as_app_validate (AsApp *app, AsAppValidateFlags flags, GError **error) if (!as_app_validate_releases (app, helper, error)) return NULL; + /* kudos */ + if (!as_app_validate_kudos (app, helper, error)) + return NULL; + /* name */ name = as_app_get_name (app, "C"); if (name != NULL) { |