From 603d5927a50c3819b39f2079ca2bc0104e0d090e Mon Sep 17 00:00:00 2001 From: JakobDev Date: Tue, 23 Aug 2022 10:03:04 +0200 Subject: [PATCH] [Validator]Don't allow bandwidth_mbitps when value is offline-only --- src/as-validator-issue-tag.h | 6 ++++++ src/as-validator.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/as-validator-issue-tag.h b/src/as-validator-issue-tag.h index 8c7db64c..df3f2399 100644 --- a/src/as-validator-issue-tag.h +++ b/src/as-validator-issue-tag.h @@ -359,6 +359,12 @@ AsValidatorIssueTag as_validator_issue_tag_list[] = { N_("The set tag value is not valid for an `internet` relation.") }, + { "relation-internet-bandwidth-offline", + AS_ISSUE_SEVERITY_WARNING, + /* TRANSLATORS: Please do not translate AppStream tag and property names (in backticks). */ + N_("The `bandwidth_mbitps` property is not allowed when using `offline-only` as value.") + }, + { "relation-internet-bandwidth-value-invalid", AS_ISSUE_SEVERITY_WARNING, N_("The value of this property must be a positive integer value, describing the minimum required bandwidth in mbit/s.") diff --git a/src/as-validator.c b/src/as-validator.c index d17e2bcd..1ee140cd 100644 --- a/src/as-validator.c +++ b/src/as-validator.c @@ -1491,6 +1491,12 @@ as_validator_check_relations (AsValidator *validator, g_autofree gchar *internet_tag_id = g_strdup_printf ("rel::%s/internet", as_relation_kind_to_string (kind)); if (as_internet_kind_from_string (content) == AS_INTERNET_KIND_UNKNOWN) as_validator_add_issue (validator, iter, "relation-internet-value-invalid", content); + + /* check if bandwidth_mbitps does not exists when value is offline-only */ + if (bandwidth_str != NULL && as_internet_kind_from_string (content) == AS_INTERNET_KIND_OFFLINE_ONLY) + as_validator_add_issue (validator, iter, "relation-internet-bandwidth-offline", NULL); + + /* check if bandwidth_mbitps is a integer */ if (bandwidth_str != NULL && !as_str_verify_integer (bandwidth_str, 1, G_MAXINT64)) as_validator_add_issue (validator, iter, "relation-internet-bandwidth-value-invalid", bandwidth_str);