mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-02 07:23:41 +02:00
Bug 620496 - schema compiler: reject invalid paths
The GSettings schema compiler was accepting any string as a path. It is probably quite a common mistake to suspect that '/apps/foo' is a valid path name when this will cause all sorts of trouble later. Check for this case and report the error.
This commit is contained in:
@@ -232,8 +232,20 @@ start_element (GMarkupParseContext *context,
|
||||
state->schema_root = gvdb_hash_table_insert (state->schema, "");
|
||||
|
||||
if (path != NULL)
|
||||
gvdb_hash_table_insert_string (state->schema,
|
||||
".path", path);
|
||||
{
|
||||
if (!g_str_has_prefix (path, "/") ||
|
||||
!g_str_has_suffix (path, "/"))
|
||||
{
|
||||
g_set_error (error, G_MARKUP_ERROR,
|
||||
G_MARKUP_ERROR_INVALID_CONTENT,
|
||||
"a path, if given, must begin and "
|
||||
"end with a slash");
|
||||
return;
|
||||
}
|
||||
|
||||
gvdb_hash_table_insert_string (state->schema,
|
||||
".path", path);
|
||||
}
|
||||
}
|
||||
else
|
||||
g_set_error (error, G_MARKUP_ERROR,
|
||||
|
Reference in New Issue
Block a user