[glib] Don't skip invalid enum values in schemas
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Don't skip invalid enum values in schemas
- Date: Wed, 11 Oct 2017 09:29:27 +0000 (UTC)
commit 12e32e96a3b124791d09ca568e922307db83fe66
Author: Maks Naumov <maksqwe1 ukr net>
Date: Thu Jan 15 14:33:17 2015 -0800
Don't skip invalid enum values in schemas
Signed-off-by: Maks Naumov <maksqwe1 ukr net>
https://bugzilla.gnome.org/show_bug.cgi?id=742997
gio/glib-compile-schemas.c | 4 ++--
gio/tests/gschema-compile.c | 1 +
.../enum-with-invalid-value.gschema.xml | 10 ++++++++++
3 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/gio/glib-compile-schemas.c b/gio/glib-compile-schemas.c
index b8de090..2dc8c71 100644
--- a/gio/glib-compile-schemas.c
+++ b/gio/glib-compile-schemas.c
@@ -97,9 +97,9 @@ enum_state_add_value (EnumState *state,
}
value = g_ascii_strtoll (valuestr, &end, 0);
- if (*end || state->is_flags ?
+ if (*end || (state->is_flags ?
(value > G_MAXUINT32 || value < 0) :
- (value > G_MAXINT32 || value < G_MININT32))
+ (value > G_MAXINT32 || value < G_MININT32)))
{
g_set_error (error, G_MARKUP_ERROR,
G_MARKUP_ERROR_INVALID_CONTENT,
diff --git a/gio/tests/gschema-compile.c b/gio/tests/gschema-compile.c
index 40a396d..99b2d1b 100644
--- a/gio/tests/gschema-compile.c
+++ b/gio/tests/gschema-compile.c
@@ -86,6 +86,7 @@ static const SchemaTest tests[] = {
{ "enum", NULL, NULL },
{ "enum-with-aliases", NULL, NULL },
{ "enum-with-invalid-alias", NULL, "*“banger” is not in enumerated type*" },
+ { "enum-with-invalid-value", NULL, "*invalid numeric value*" },
{ "enum-with-repeated-alias", NULL, "*<alias value='sausages'/> already specified*" },
{ "enum-with-repeated-nick", NULL, "*<value nick='spam'/> already specified*" },
{ "enum-with-repeated-value", NULL, "*value='1' already specified*" },
diff --git a/gio/tests/schema-tests/enum-with-invalid-value.gschema.xml
b/gio/tests/schema-tests/enum-with-invalid-value.gschema.xml
new file mode 100644
index 0000000..02071e0
--- /dev/null
+++ b/gio/tests/schema-tests/enum-with-invalid-value.gschema.xml
@@ -0,0 +1,10 @@
+<schemalist>
+ <enum id='org.gtk.test.MyEnum'>
+ <value nick='nospam' value='*'/>
+ <value nick='spam' value='1'/>
+ <value nick='ham' value='2'/>
+ <value nick='eggs' value='3'/>
+ <value nick='bangers' value='4'/>
+ <value nick='mash' value='5'/>
+ </enum>
+</schemalist>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]