[glib] guuid: Remove support for curly braces and URN UUIDs



commit 4b75333c83535cef57f674f5bd0c604901c44d1d
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Feb 3 14:27:21 2017 +0100

    guuid: Remove support for curly braces and URN UUIDs
    
    As we currently cannot generate UUIDs with curly braces, or as URNs,
    remove those from the possible valid UUIDs.
    
    We do this separately to make it easier to re-add later, should we want
    to enhance the coverage of our UUID functions.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=639078

 glib/guuid.c       |   23 +----------------------
 glib/tests/guuid.c |    4 ++--
 2 files changed, 3 insertions(+), 24 deletions(-)
---
diff --git a/glib/guuid.c b/glib/guuid.c
index 0f48bfb..1adc6c8 100644
--- a/glib/guuid.c
+++ b/glib/guuid.c
@@ -94,27 +94,9 @@ uuid_parse_string (const gchar *str,
   gint i, j, hi, lo;
   guint expected_len = 36;
 
-  if (g_str_has_prefix (str, "urn:uuid:"))
-    str += 9;
-  else if (g_str_has_prefix (str, "{urn:uuid:"))
-    expected_len += 11;
-  else if (str[0] == '{')
-    expected_len += 2;
-
   if (strlen (str) != expected_len)
     return FALSE;
 
-  if (str[0] == '{')
-    {
-      if (str[expected_len - 1] != '}')
-        return FALSE;
-
-      str++;
-    }
-
-  if (g_str_has_prefix (str, "urn:uuid:"))
-    str += 9;
-
   for (i = 0, j = 0; i < 16;)
     {
       if (j == 8 || j == 13 || j == 18 || j == 23)
@@ -146,12 +128,9 @@ uuid_parse_string (const gchar *str,
  *
  * Parses the string @str and verify if it is a UUID.
  *
- * The function accepts the following syntaxes:
+ * The function accepts the following syntax:
  *
  * - simple forms (e.g. `f81d4fae-7dec-11d0-a765-00a0c91e6bf6`)
- * - simple forms with curly braces (e.g.
- *   `{urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6}`)
- * - URN (e.g. `urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6`)
  *
  * Note that hyphens are required within the UUID string itself,
  * as per the aforementioned RFC.
diff --git a/glib/tests/guuid.c b/glib/tests/guuid.c
index 437749f..41e2c81 100644
--- a/glib/tests/guuid.c
+++ b/glib/tests/guuid.c
@@ -30,13 +30,13 @@ test_guuid_string (void)
   g_assert_false (g_uuid_string_is_valid ("00010203-0405-0607-0809"));
   g_assert_false (g_uuid_string_is_valid ("zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz"));
   g_assert_false (g_uuid_string_is_valid ("000102030405060708090a0b0c0d0e0f"));
+  g_assert_false (g_uuid_string_is_valid ("{urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6}"));
+  g_assert_false (g_uuid_string_is_valid ("urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6"));
 
   g_assert_true (g_uuid_string_is_valid ("00010203-0405-0607-0809-0a0b0c0d0e0f"));
   g_assert_true (g_uuid_string_is_valid ("7d444840-9dc0-11d1-b245-5ffdce74fad2"));
   g_assert_true (g_uuid_string_is_valid ("e902893a-9d22-3c7e-a7b8-d6e313b71d9f"));
   g_assert_true (g_uuid_string_is_valid ("6ba7b810-9dad-11d1-80b4-00c04fd430c8"));
-  g_assert_true (g_uuid_string_is_valid ("{urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6}"));
-  g_assert_true (g_uuid_string_is_valid ("urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6"));
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]