diff options
author | Otto Urpelainen <oturpe@iki.fi> | 2021-05-13 23:21:34 +0300 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2021-05-18 13:31:18 +0100 |
commit | cf73b762112730acfd4f7b11594a30a2b49e2443 (patch) | |
tree | 1241d3198362ccf7ba65342e263228b33bd429c2 /libappstream-glib/as-app.c | |
parent | 462dcd2b74dbeec45d900603320c8d9074f13cc9 (diff) | |
download | appstream-glib-cf73b762112730acfd4f7b11594a30a2b49e2443.tar.gz |
Add validation for duplicate license xml elements
AppStream license syntax allows constructs of form "LICENSE1 AND
LICENSE2". It is possible to confuse this with writing multiple license
xml elements in a metainfo file. In order to spot this type of error,
duplicate detection is added for xml elements metadata_license and
project_license.
Diffstat (limited to 'libappstream-glib/as-app.c')
-rw-r--r-- | libappstream-glib/as-app.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/libappstream-glib/as-app.c b/libappstream-glib/as-app.c index 2caba19..3939970 100644 --- a/libappstream-glib/as-app.c +++ b/libappstream-glib/as-app.c @@ -5154,15 +5154,19 @@ as_app_node_parse_child (AsApp *app, GNode *n, guint32 flags, priv->problems |= AS_APP_PROBLEM_TRANSLATED_LICENSE; break; } + if (priv->project_license != NULL) + priv->problems |= AS_APP_PROBLEM_DUPLICATE_PROJECT_LICENSE; as_ref_string_assign (&priv->project_license, as_node_get_data_as_refstr (n)); break; - /* <project_license> */ + /* <metadata_license> */ case AS_TAG_METADATA_LICENSE: if (as_node_get_attribute (n, "xml:lang") != NULL) { priv->problems |= AS_APP_PROBLEM_TRANSLATED_LICENSE; break; } + if (priv->metadata_license != NULL) + priv->problems |= AS_APP_PROBLEM_DUPLICATE_METADATA_LICENSE; as_app_set_metadata_license (app, as_node_get_data (n)); break; |