Skip to content

Commit

Permalink
validator: Check for common typo of "scheme_preference" branding prop…
Browse files Browse the repository at this point in the history
…erty

Resolves: #626
  • Loading branch information
ximion committed Apr 3, 2024
1 parent 709d9ac commit 0d06a89
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/as-validator-issue-tag.h
Original file line number Diff line number Diff line change
Expand Up @@ -1133,6 +1133,12 @@ AsValidatorIssueTag as_validator_issue_tag_list[] = {
N_("The value of this color scheme preference is not valid."),
},

{ "branding-color-scheme-wrong-property",
AS_ISSUE_SEVERITY_ERROR,
/* TRANSLATORS: Please do not translate AppStream tag and property names (in backticks). */
N_("The name of the color scheme property is wrong. It should be `scheme_preference`."),
},

{ "branding-color-invalid",
AS_ISSUE_SEVERITY_ERROR,
N_("This color is not a valid HTML color code."),
Expand Down
10 changes: 10 additions & 0 deletions src/as-validator.c
Original file line number Diff line number Diff line change
Expand Up @@ -2947,6 +2947,16 @@ as_validator_check_branding (AsValidator *validator, xmlNode *node)
tmp);
g_free (tmp);

/* catch a common typo */
tmp = as_xml_get_prop_value (iter, "schema_preference");
if (tmp != NULL)
as_validator_add_issue (validator,
iter,
"branding-color-scheme-wrong-property",
"%s",
"schema_preference");
g_free (tmp);

tmp = as_xml_get_node_value (iter);
len = strlen (tmp);
if (!g_str_has_prefix (tmp, "#") || (len != 7 && len != 9))
Expand Down

0 comments on commit 0d06a89

Please sign in to comment.