Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if URL type is redefined #407

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -442,6 +442,12 @@ AsValidatorIssueTag as_validator_issue_tag_list[] = {
N_("Invalid `type` property for this `url` tag. URLs of this type are not known in the AppStream specification."),
},

{ "url-type-redefined",
AS_ISSUE_SEVERITY_WARNING,
/* TRANSLATORS: Please do not translate AppStream tag and property names (in backticks). */
N_("This relation item has already been defined."),
},

{ "url-not-reachable",
AS_ISSUE_SEVERITY_WARNING,
N_("Unable to reach remote location that this URL references - does it exist?"),
@@ -1881,6 +1881,7 @@ as_validator_validate_component_node (AsValidator *validator, AsContext *ctx, xm
g_autofree gchar *cpttype = NULL;
g_autoptr(GHashTable) found_tags = NULL;
g_autoptr(GHashTable) known_relation_items = NULL;
g_autoptr(GHashTable) known_url_types = NULL;
g_autofree gchar *date_eol_str = NULL;

AsFormatStyle mode;
@@ -1889,6 +1890,7 @@ as_validator_validate_component_node (AsValidator *validator, AsContext *ctx, xm
/* hash tables for finding duplicates */
found_tags = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
known_relation_items = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
known_url_types = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);

mode = as_context_get_style (ctx);

@@ -2050,6 +2052,15 @@ as_validator_validate_component_node (AsValidator *validator, AsContext *ctx, xm
node_content,
"url-not-reachable");

if (prop) {
if (g_hash_table_lookup (known_url_types, prop) == NULL) {
g_hash_table_insert (known_url_types, g_strdup(prop), g_strdup(""));
}
else {
as_validator_add_issue (validator, iter, "url-type-redefined", prop);
}
}

} else if (g_strcmp0 (node_name, "categories") == 0) {
as_validator_check_appear_once (validator, iter, found_tags);
as_validator_check_children_quick (validator, iter, "category", FALSE);