uri: there are valid URI protocols with only two letters, like fd://
authorTim-Philipp Müller <tim.muller@collabora.co.uk>
Wed, 4 Jul 2012 16:36:55 +0000 (17:36 +0100)
committerTim-Philipp Müller <tim.muller@collabora.co.uk>
Wed, 4 Jul 2012 16:39:52 +0000 (17:39 +0100)
We added a minimum length of three letters originally so we would
fail to recognise DOS/Windows-style filenames as valid URIs (as we
should). Two should be just fine as well.

gst/gsturi.c
tests/check/gst/gsturi.c

index 882abdf..cd77fd8 100644 (file)
@@ -314,7 +314,7 @@ gst_uri_protocol_is_valid (const gchar * protocol)
 
   gst_uri_protocol_check_internal (protocol, &endptr);
 
-  return *endptr == '\0' && ((gsize) (endptr - protocol)) >= 3;
+  return *endptr == '\0' && ((gsize) (endptr - protocol)) >= 2;
 }
 
 /**
@@ -335,7 +335,7 @@ gst_uri_is_valid (const gchar * uri)
 
   gst_uri_protocol_check_internal (uri, &endptr);
 
-  return *endptr == ':' && ((gsize) (endptr - uri)) >= 3;
+  return *endptr == ':' && ((gsize) (endptr - uri)) >= 2;
 }
 
 /**
index 3c044fe..259b3a0 100644 (file)
@@ -112,16 +112,17 @@ GST_END_TEST;
 
 GST_START_TEST (test_uri_misc)
 {
-  /* require at least three characters for the protocol */
+  /* require at least two characters for the protocol */
   fail_if (gst_uri_is_valid ("B:\\foo.txt"));
   fail_if (gst_uri_is_valid ("B:/foo.txt"));
   fail_if (gst_uri_is_valid ("B://foo.txt"));
   fail_if (gst_uri_is_valid ("B:foo.txt"));
 
-  fail_if (gst_uri_is_valid ("AB:\\foo.txt"));
-  fail_if (gst_uri_is_valid ("AB:/foo.txt"));
-  fail_if (gst_uri_is_valid ("AB://foo.txt"));
-  fail_if (gst_uri_is_valid ("AB:foo.txt"));
+  fail_unless (gst_uri_is_valid ("fd://0"));
+  fail_unless (gst_uri_is_valid ("AB:\\foo.txt"));
+  fail_unless (gst_uri_is_valid ("AB:/foo.txt"));
+  fail_unless (gst_uri_is_valid ("AB://foo.txt"));
+  fail_unless (gst_uri_is_valid ("AB:foo.txt"));
 
   fail_unless (gst_uri_is_valid ("ABC:/foo.txt"));
   fail_unless (gst_uri_is_valid ("ABC://foo.txt"));