GNOME Bugzilla – Bug 550110
RFC: g_uri_is_valid (from GStreamer gst_uri_is_valid)
Last modified: 2015-03-26 15:32:58 UTC
This function could very well server other purposes than in GStreamer only, at least in my case ;) Adapted from GStreamer gsturi.c static void g_uri_is_valid (const gchar * uri) { gchar *check = (gchar *) uri; g_assert (uri != NULL); if (g_ascii_isalpha (*check)) { check++; while (g_ascii_isalnum (*check) || *check == '+' || *check == '-' || *check == '.') check++; } return check == ':'; }
obviously missing some stuff now that I compile it: gboolean g_uri_is_valid (const gchar * uri) { gchar *check = (gchar *) uri; g_assert (uri != NULL); if (g_ascii_isalpha (*check)) { check++; while (g_ascii_isalnum (*check) || *check == '+' || *check == '-' || *check == '.') check++; } return *check == ':'; }
*** Bug 534169 has been marked as a duplicate of this bug. ***
This is a very weak validity check. For instance, it allows non-ascii after the colon, which I'm not sure is valid. However, validation is a very tricky thing in general, so we should imho do minimal absolutely correct validation, and then document exactly what we mean by a uri being "valid".
bug 489862 provides a much better g_uri_is_valid(), let's close as dup *** This bug has been marked as a duplicate of bug 489862 ***