mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-11 23:16:14 +01:00
GSettings: be more careful about keys names with /
Prevent attempts to access keys ending with slashes that exist in the schema file as references to child schemas. Also: don't emit change signals for these same keys.
This commit is contained in:
parent
52a6d7022a
commit
ed492a5de2
@ -279,8 +279,14 @@ g_settings_real_change_event (GSettings *settings,
|
|||||||
keys = g_settings_schema_list (settings->priv->schema, &n_keys);
|
keys = g_settings_schema_list (settings->priv->schema, &n_keys);
|
||||||
|
|
||||||
for (i = 0; i < n_keys; i++)
|
for (i = 0; i < n_keys; i++)
|
||||||
g_signal_emit (settings, g_settings_signals[SIGNAL_CHANGED],
|
{
|
||||||
keys[i], g_quark_to_string (keys[i]));
|
const gchar *key = g_quark_to_string (keys[i]);
|
||||||
|
|
||||||
|
if (g_str_has_suffix (key, "/"))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
g_signal_emit (settings, g_settings_signals[SIGNAL_CHANGED], keys[i], key);
|
||||||
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -297,8 +303,14 @@ g_settings_real_writable_change_event (GSettings *settings,
|
|||||||
keys = g_settings_schema_list (settings->priv->schema, &n_keys);
|
keys = g_settings_schema_list (settings->priv->schema, &n_keys);
|
||||||
|
|
||||||
for (i = 0; i < n_keys; i++)
|
for (i = 0; i < n_keys; i++)
|
||||||
g_signal_emit (settings, g_settings_signals[SIGNAL_WRITABLE_CHANGED],
|
{
|
||||||
keys[i], g_quark_to_string (keys[i]));
|
const gchar *key = g_quark_to_string (keys[i]);
|
||||||
|
|
||||||
|
if (g_str_has_suffix (key, "/"))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
g_signal_emit (settings, g_settings_signals[SIGNAL_WRITABLE_CHANGED], keys[i], key);
|
||||||
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -636,7 +636,7 @@ g_settings_schema_get_value (GSettingsSchema *schema,
|
|||||||
|
|
||||||
value = gvdb_table_get_raw_value (schema->table, key);
|
value = gvdb_table_get_raw_value (schema->table, key);
|
||||||
|
|
||||||
if G_UNLIKELY (value == NULL)
|
if G_UNLIKELY (value == NULL || !g_variant_is_of_type (value, G_VARIANT_TYPE_TUPLE))
|
||||||
g_error ("Settings schema '%s' does not contain a key named '%s'", schema->id, key);
|
g_error ("Settings schema '%s' does not contain a key named '%s'", schema->id, key);
|
||||||
|
|
||||||
iter = g_variant_iter_new (value);
|
iter = g_variant_iter_new (value);
|
||||||
|
Loading…
Reference in New Issue
Block a user