summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2014-06-16 09:34:56 +0100
committerRichard Hughes <richard@hughsie.com>2014-06-16 09:34:56 +0100
commit0a00ac1ec40201eb388d192cab1c55cddc32636a (patch)
treeab41164040f7869cf6ab0a50f0b0c04c0dfa0917
parentcc77a53df18464969447420450e571b8074e4957 (diff)
downloadappstream-glib-0a00ac1ec40201eb388d192cab1c55cddc32636a.tar.gz
Validate the <developer_name> tag values
-rw-r--r--libappstream-glib/as-app-validate.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/libappstream-glib/as-app-validate.c b/libappstream-glib/as-app-validate.c
index 7f0b28d..44d84f2 100644
--- a/libappstream-glib/as-app-validate.c
+++ b/libappstream-glib/as-app-validate.c
@@ -109,6 +109,19 @@ as_app_validate_has_hyperlink (const gchar *text)
}
/**
+ * as_app_validate_has_email:
+ **/
+static gboolean
+as_app_validate_has_email (const gchar *text)
+{
+ if (g_strstr_len (text, -1, "@") != NULL)
+ return TRUE;
+ if (g_strstr_len (text, -1, "_at_") != NULL)
+ return TRUE;
+ return FALSE;
+}
+
+/**
* as_app_validate_description_li:
**/
static void
@@ -1077,6 +1090,32 @@ as_app_validate (AsApp *app, AsAppValidateFlags flags, GError **error)
}
}
+ /* developer_name */
+ name = as_app_get_developer_name (app, NULL);
+ if (name != NULL) {
+ str_len = strlen (name);
+ if (str_len < length_name_min) {
+ ai_app_validate_add (probs,
+ AS_PROBLEM_KIND_STYLE_INCORRECT,
+ "<developer_name> is too short");
+ }
+ if (str_len > length_name_max) {
+ ai_app_validate_add (probs,
+ AS_PROBLEM_KIND_STYLE_INCORRECT,
+ "<developer_name> is too long");
+ }
+ if (as_app_validate_has_hyperlink (name)) {
+ ai_app_validate_add (probs,
+ AS_PROBLEM_KIND_STYLE_INCORRECT,
+ "<developer_name> cannot contain a hyperlink");
+ }
+ if (as_app_validate_has_email (name)) {
+ ai_app_validate_add (probs,
+ AS_PROBLEM_KIND_STYLE_INCORRECT,
+ "<developer_name> cannot contain an email address");
+ }
+ }
+
/* using deprecated names */
if (deprectated_failure && (problems & AS_APP_PROBLEM_DEPRECATED_LICENCE) > 0) {
ai_app_validate_add (probs,