Accept '/', '+' and '.' in key names, since gnome-vfs uses mime types as
authorMatthias Clasen <mclasen@redhat.com>
Tue, 19 Dec 2006 21:08:32 +0000 (21:08 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Tue, 19 Dec 2006 21:08:32 +0000 (21:08 +0000)
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

ChangeLog
glib/gkeyfile.c
tests/keyfile-test.c

index a8d29f0..d119d73 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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,
index 4e47b65..ca4b763 100644 (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 == '[')
index 4ad908b..17271c7 100644 (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";
@@ -1100,15 +1090,6 @@ test_key_names (void)
 
   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");
   value = g_key_file_get_string (keyfile, "a", "key\tfoo", &error);
   check_error (&error, 
@@ -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);  
 }