diff options
author | Havoc Pennington <hp@redhat.com> | 2001-10-13 00:13:02 +0000 |
---|---|---|
committer | Havoc Pennington <hp@src.gnome.org> | 2001-10-13 00:13:02 +0000 |
commit | e81797bae5adc124a4953dd273cb723c0d7e5651 (patch) | |
tree | f4a63682bd198d9030f61ee42e0c29da66d52651 /gconf/gconf-value.c | |
parent | 15faad1f03d742ac36259fbfe5ddc7b94c3bf1c5 (diff) | |
download | gconf-e81797bae5adc124a4953dd273cb723c0d7e5651.tar.gz |
check UTF-8 validity here, instead of at the higher levels
2001-10-12 Havoc Pennington <hp@redhat.com>
* 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
Diffstat (limited to 'gconf/gconf-value.c')
-rw-r--r-- | gconf/gconf-value.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/gconf/gconf-value.c b/gconf/gconf-value.c index f5389db2..781130fa 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; +} |