From 3329f3f4e4d781c58a80584c460f664709312ebf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Wed, 4 Jul 2012 17:36:55 +0100 Subject: [PATCH] uri: there are valid URI protocols with only two letters, like fd:// 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 | 4 ++-- tests/check/gst/gsturi.c | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/gst/gsturi.c b/gst/gsturi.c index 882abdf..cd77fd8 100644 --- a/gst/gsturi.c +++ b/gst/gsturi.c @@ -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; } /** diff --git a/tests/check/gst/gsturi.c b/tests/check/gst/gsturi.c index 3c044fe..259b3a0 100644 --- a/tests/check/gst/gsturi.c +++ b/tests/check/gst/gsturi.c @@ -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")); -- 2.7.4