summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2001-10-13 00:16:14 +0000
committerHavoc Pennington <hp@src.gnome.org>2001-10-13 00:16:14 +0000
commit51b176c0f69b10cbeed19c829328065172f11fce (patch)
tree6b8fe021111fc81cec4b2aa4aab0cbfac4972a6b
parent4d837029eebbb84488974ecc9286e21f1a6e4762 (diff)
downloadgconf-51b176c0f69b10cbeed19c829328065172f11fce.tar.gz
Merge from stable.
2001-10-12 Havoc Pennington <hp@redhat.com> Merge from stable. * gconf/gconf.c (gconf_engine_set): check UTF-8 validity here, instead of at the higher levels * gconf/gconf-value.c (gconf_value_validate): new internal function
-rw-r--r--ChangeLog9
-rw-r--r--gconf/gconf-internals.h8
-rw-r--r--gconf/gconf-value.c29
-rw-r--r--gconf/gconf.c14
4 files changed, 47 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 869d13ba..32c88e9a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,15 @@
Merge from stable.
+ * gconf/gconf.c (gconf_engine_set): check UTF-8 validity here,
+ instead of at the higher levels
+
+ * gconf/gconf-value.c (gconf_value_validate): new internal function
+
+2001-10-12 Havoc Pennington <hp@redhat.com>
+
+ Merge from stable.
+
* tests/testschemas.c (check_schema_storage): add some UTF-8
* tests/testpersistence.c: UTF-8 test
diff --git a/gconf/gconf-internals.h b/gconf/gconf-internals.h
index 47785758..b738bbd4 100644
--- a/gconf/gconf-internals.h
+++ b/gconf/gconf-internals.h
@@ -196,8 +196,12 @@ ConfigServer gconf_activate_server (gboolean start_if_not_found,
char* gconf_get_lock_dir (void);
char* gconf_get_daemon_dir (void);
-gboolean gconf_schema_validate (const GConfSchema *sc,
- GError **err);
+gboolean gconf_schema_validate (const GConfSchema *sc,
+ GError **err);
+gboolean gconf_value_validate (GConfValue *value,
+ GError **err);
+
+
#ifdef ENABLE_NLS
# include <libintl.h>
diff --git a/gconf/gconf-value.c b/gconf/gconf-value.c
index 2bfbc3e2..dcad8341 100644
--- a/gconf/gconf-value.c
+++ b/gconf/gconf-value.c
@@ -1069,3 +1069,32 @@ gconf_entry_set_is_writable (GConfEntry *entry,
}
+gboolean
+gconf_value_validate (GConfValue *value,
+ GError **err)
+{
+ switch (value->type)
+ {
+ case GCONF_VALUE_STRING:
+ if (value->d.string_data &&
+ !g_utf8_validate (value->d.string_data, -1, NULL))
+ {
+ g_set_error (err, GCONF_ERROR,
+ GCONF_ERROR_FAILED,
+ _("Text contains invalid UTF-8"));
+ return FALSE;
+ }
+ break;
+
+ case GCONF_VALUE_SCHEMA:
+ if (value->d.schema_data)
+ return gconf_schema_validate (value->d.schema_data,
+ err);
+ break;
+
+ default:
+ break;
+ }
+
+ return TRUE;
+}
diff --git a/gconf/gconf.c b/gconf/gconf.c
index e50e1d56..066f5c02 100644
--- a/gconf/gconf.c
+++ b/gconf/gconf.c
@@ -991,6 +991,9 @@ gconf_engine_set (GConfEngine* conf, const gchar* key,
if (!gconf_key_check(key, err))
return FALSE;
+ if (!gconf_value_validate (value, err))
+ return FALSE;
+
if (gconf_engine_is_local(conf))
{
GError* error = NULL;
@@ -2974,14 +2977,6 @@ gconf_engine_set_string (GConfEngine* conf, const gchar* key,
g_return_val_if_fail (conf != NULL, FALSE);
g_return_val_if_fail (key != NULL, FALSE);
g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
-
- if (!g_utf8_validate (val, -1, NULL))
- {
- g_set_error (err, GCONF_ERROR,
- GCONF_ERROR_FAILED,
- _("Text contains invalid UTF-8"));
- return FALSE;
- }
g_return_val_if_fail (g_utf8_validate (val, -1, NULL), FALSE);
@@ -3019,9 +3014,6 @@ gconf_engine_set_schema (GConfEngine* conf, const gchar* key,
g_return_val_if_fail(key != NULL, FALSE);
g_return_val_if_fail(val != NULL, FALSE);
g_return_val_if_fail(err == NULL || *err == NULL, FALSE);
-
- if (!gconf_schema_validate (val, err))
- return FALSE;
gval = gconf_value_new(GCONF_VALUE_SCHEMA);