summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2014-06-16 14:20:34 +0100
committerRichard Hughes <richard@hughsie.com>2014-06-16 14:20:34 +0100
commita1ff13040b18bbc8fc0dcb08eb622d3738611177 (patch)
tree61db04d4d26e563324172e76ba6accf7572a0d90
parent05d5a45aa1b8dd560740db940ed2c8d5878a9943 (diff)
downloadappstream-glib-a1ff13040b18bbc8fc0dcb08eb622d3738611177.tar.gz
Allow any SPDX license when validating in relaxed mode
-rw-r--r--libappstream-glib/as-app-validate.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/libappstream-glib/as-app-validate.c b/libappstream-glib/as-app-validate.c
index 44d84f2..338ed15 100644
--- a/libappstream-glib/as-app-validate.c
+++ b/libappstream-glib/as-app-validate.c
@@ -783,6 +783,7 @@ as_app_validate (AsApp *app, AsAppValidateFlags flags, GError **error)
gboolean require_project_license = FALSE;
gboolean require_translations = FALSE;
gboolean require_url = TRUE;
+ gboolean require_content_license = TRUE;
gboolean ret;
guint length_name_max = 30;
guint length_name_min = 3;
@@ -798,6 +799,7 @@ as_app_validate (AsApp *app, AsAppValidateFlags flags, GError **error)
length_name_max = 100;
length_summary_max = 200;
require_contactdetails = FALSE;
+ require_content_license = FALSE;
require_url = FALSE;
number_para_max = 10;
number_para_min = 1;
@@ -809,6 +811,7 @@ as_app_validate (AsApp *app, AsAppValidateFlags flags, GError **error)
require_copyright = TRUE;
require_translations = TRUE;
require_project_license = TRUE;
+ require_content_license = TRUE;
}
/* set up networking */
@@ -870,13 +873,25 @@ as_app_validate (AsApp *app, AsAppValidateFlags flags, GError **error)
/* metadata_license */
license = as_app_get_metadata_license (app);
if (license != NULL) {
- if (g_strcmp0 (license, "CC0-1.0") != 0 &&
- g_strcmp0 (license, "CC-BY-3.0") != 0 &&
- g_strcmp0 (license, "CC-BY-SA-3.0") != 0 &&
- g_strcmp0 (license, "GFDL-1.3") != 0) {
- ai_app_validate_add (probs,
- AS_PROBLEM_KIND_TAG_INVALID,
- "<metadata_license> is not valid");
+ if (require_content_license) {
+ if (g_strcmp0 (license, "CC0-1.0") != 0 &&
+ g_strcmp0 (license, "CC-BY-3.0") != 0 &&
+ g_strcmp0 (license, "CC-BY-SA-3.0") != 0 &&
+ g_strcmp0 (license, "GFDL-1.3") != 0) {
+ ai_app_validate_add (probs,
+ AS_PROBLEM_KIND_TAG_INVALID,
+ "<metadata_license> is not valid");
+ }
+ } else {
+ ret = as_app_validate_license (license, &error_local);
+ if (!ret) {
+ g_prefix_error (&error_local,
+ "<metadata_license> is not valid: ");
+ ai_app_validate_add (probs,
+ AS_PROBLEM_KIND_TAG_INVALID,
+ error_local->message);
+ g_clear_error (&error_local);
+ }
}
}
if (license == NULL) {