After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 550110 - RFC: g_uri_is_valid (from GStreamer gst_uri_is_valid)
RFC: g_uri_is_valid (from GStreamer gst_uri_is_valid)
Status: RESOLVED DUPLICATE of bug 489862
Product: glib
Classification: Platform
Component: general
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: gtkdev
gtkdev
: 534169 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2008-08-31 19:34 UTC by Marc-Andre Lureau
Modified: 2015-03-26 15:32 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Marc-Andre Lureau 2008-08-31 19:34:01 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 == ':';
}
Comment 1 Marc-Andre Lureau 2008-08-31 19:38:33 UTC
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 == ':';
}
Comment 2 Matthias Clasen 2008-09-02 16:29:49 UTC
*** Bug 534169 has been marked as a duplicate of this bug. ***
Comment 3 Alexander Larsson 2008-09-25 09:07:07 UTC
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".
Comment 4 Marc-Andre Lureau 2015-03-26 15:32:58 UTC
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 ***