[gnome-builder] create-project: improve name validation
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] create-project: improve name validation
- Date: Sat, 10 Sep 2016 02:47:50 +0000 (UTC)
commit 4cf83eb22604181c1290d475a1776807adb4d74e
Author: Christian Hergert <chergert redhat com>
Date: Fri Sep 9 19:46:36 2016 -0700
create-project: improve name validation
Don't allow names starting with a digit, nor names containing whitespace.
https://bugzilla.gnome.org/show_bug.cgi?id=771143
plugins/create-project/gbp-create-project-widget.c | 9 +++++++++
.../create-project/gbp-create-project-widget.ui | 2 +-
2 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/plugins/create-project/gbp-create-project-widget.c
b/plugins/create-project/gbp-create-project-widget.c
index c915180..d943393 100644
--- a/plugins/create-project/gbp-create-project-widget.c
+++ b/plugins/create-project/gbp-create-project-widget.c
@@ -99,10 +99,19 @@ gbp_create_project_widget_add_languages (GbpCreateProjectWidget *self,
static gboolean
validate_name (const gchar *name)
{
+ if (name == NULL)
+ return FALSE;
+
+ if (g_unichar_isdigit (g_utf8_get_char (name)))
+ return FALSE;
+
for (; *name; name = g_utf8_next_char (name))
{
gunichar ch = g_utf8_get_char (name);
+ if (g_unichar_isspace (ch))
+ return FALSE;
+
if (ch == '/')
return FALSE;
}
diff --git a/plugins/create-project/gbp-create-project-widget.ui
b/plugins/create-project/gbp-create-project-widget.ui
index e247a78..5b3bf01 100644
--- a/plugins/create-project/gbp-create-project-widget.ui
+++ b/plugins/create-project/gbp-create-project-widget.ui
@@ -109,7 +109,7 @@
<property name="wrap">true</property>
<property name="visible">true</property>
<property name="max-width-chars">60</property>
- <property name="label" translatable="yes">Unique name that is used for your
project's folder and other technical resources. Should be in lower case without spaces.</property>
+ <property name="label" translatable="yes">Unique name that is used for your
project's folder and other technical resources. Should be in lower case without spaces and may not start with
a number.</property>
<style>
<class name="dim-label"/>
</style>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]