Accept '/', '+' and '.' in key names, since gnome-vfs uses mime types as

2006-12-19  Matthias Clasen  <mclasen@redhat.com>

        * glib/gkeyfile.c (g_key_file_is_key_name): Accept
        '/', '+' and '.' in key names, since gnome-vfs uses
        mime types as keys in some cache.

2
This commit is contained in:
Matthias Clasen 2006-12-19 21:08:32 +00:00 committed by Matthias Clasen
parent 493e7ca45f
commit 01f78fa7f5
3 changed files with 24 additions and 20 deletions

View File

@ -1,3 +1,11 @@
2006-12-19 Matthias Clasen <mclasen@redhat.com>
* glib/gkeyfile.c (g_key_file_is_key_name): Accept
'/', '+' and '.' in key names, since gnome-vfs uses
mime types as keys in some cache.
* tests/keyfile-test.c: Tests for the above.
2006-12-18 Matthias Clasen <mclasen@redhat.com>
* configure.in: Fix the broken poll test. (#387260,

View File

@ -3234,7 +3234,11 @@ g_key_file_is_key_name (const gchar *name)
return FALSE;
p = q = (gchar *) name;
while (*q && (g_unichar_isalnum (g_utf8_get_char (q)) || *q == '-'))
/* We accept a little more than the desktop entry spec says,
* since gnome-vfs uses mime-types as keys in its cache.
*/
while (*q && (g_unichar_isalnum (g_utf8_get_char (q)) ||
*q == '-' || *q == '_' || *q == '/' || *q == '+' || *q == '.'))
q = g_utf8_next_char (q);
if (*q == '[')

View File

@ -1052,16 +1052,6 @@ test_key_names (void)
G_KEY_FILE_ERROR,
G_KEY_FILE_ERROR_PARSE);
/* + in key name */
data = "[a]\n"
"key+foo=123\n";
keyfile = g_key_file_new ();
g_key_file_load_from_data (keyfile, data, -1, 0, &error);
g_key_file_free (keyfile);
check_error (&error,
G_KEY_FILE_ERROR,
G_KEY_FILE_ERROR_PARSE);
/* control char in key name */
data = "[a]\n"
"key\tfoo=123\n";
@ -1098,15 +1088,6 @@ test_key_names (void)
G_KEY_FILE_ERROR_KEY_NOT_FOUND);
g_key_file_free (keyfile);
keyfile = g_key_file_new ();
g_key_file_set_string (keyfile, "a", "x", "123");
g_key_file_set_string (keyfile, "a", "key+foo", "123");
value = g_key_file_get_string (keyfile, "a", "key+foo", &error);
check_error (&error,
G_KEY_FILE_ERROR,
G_KEY_FILE_ERROR_KEY_NOT_FOUND);
g_key_file_free (keyfile);
keyfile = g_key_file_new ();
g_key_file_set_string (keyfile, "a", "x", "123");
g_key_file_set_string (keyfile, "a", "key\tfoo", "123");
@ -1127,8 +1108,19 @@ test_key_names (void)
keyfile = g_key_file_new ();
g_key_file_set_string (keyfile, "a", "x", "123");
/* Unicode key */
g_key_file_set_string (keyfile, "a", "\xc2\xbd", "123");
check_string_value (keyfile, "a", "\xc2\xbd", "123");
/* Keys with / + . (as used by the gnome-vfs mime cache) */
g_key_file_set_string (keyfile, "a", "foo/bar", "/");
check_string_value (keyfile, "a", "foo/bar", "/");
g_key_file_set_string (keyfile, "a", "foo+bar", "+");
check_string_value (keyfile, "a", "foo+bar", "+");
g_key_file_set_string (keyfile, "a", "foo.bar", ".");
check_string_value (keyfile, "a", "foo.bar", ".");
g_key_file_free (keyfile);
}