diff --git a/src/as-validator-issue-tag.h b/src/as-validator-issue-tag.h index df3f23993..6c9852a5e 100644 --- a/src/as-validator-issue-tag.h +++ b/src/as-validator-issue-tag.h @@ -106,6 +106,11 @@ AsValidatorIssueTag as_validator_issue_tag_list[] = { N_("The mentioned tag is empty, which is highly likely not intended as it should have content.") }, + { "tag-invalid-text-content", + AS_ISSUE_SEVERITY_ERROR, + N_("The mentioned tag has text content, even though it is not allowed to contain text.") + }, + { "cid-is-not-rdns", AS_ISSUE_SEVERITY_ERROR, N_("The component ID is required to follow a reverse domain-name scheme for its name. See the AppStream specification for details.") diff --git a/src/as-validator.c b/src/as-validator.c index 5b7809ad8..27de13f0b 100644 --- a/src/as-validator.c +++ b/src/as-validator.c @@ -644,12 +644,29 @@ as_validate_is_secure_url (const gchar *str) return FALSE; } +/** + * as_validator_ensure_node_no_text: + * + * Check that the given node has no text content. + **/ +static void +as_validator_ensure_node_no_text (AsValidator *validator, xmlNode *node) +{ + if (node == NULL) + return; + if (xmlNodeIsText (node) || xmlNodeIsText (node->children)) + as_validator_add_issue (validator, node, + "tag-invalid-text-content", + (const gchar*) node->name); +} + /** * as_validator_check_children_quick: **/ static void as_validator_check_children_quick (AsValidator *validator, xmlNode *node, const gchar *allowed_tagname, gboolean allow_empty) { + as_validator_ensure_node_no_text (validator, node); for (xmlNode *iter = node->children; iter != NULL; iter = iter->next) { const gchar *node_name; /* discard spaces */ @@ -1350,6 +1367,7 @@ as_validator_check_relations (AsValidator *validator, GHashTable *known_entries, AsRelationKind kind) { + as_validator_ensure_node_no_text (validator, node); for (xmlNode *iter = node->children; iter != NULL; iter = iter->next) { const gchar *node_name; const gchar *rel_dupe_type = NULL;