summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorSebastian Dröge <slomo@circular-chaos.org>2007-02-02 10:41:29 +0000
committerSebastian Dröge <slomo@circular-chaos.org>2007-02-02 10:41:29 +0000
commitb3c3d335cfc2f6637977932fd96eaded52b32221 (patch)
tree1e2150aedcdc42c1f6f1fe61502ff7d6e3664fbb /plugins
parentc50cb6a421b36e10f3bf90b7606a57735c6d719c (diff)
downloadgstreamer-b3c3d335cfc2f6637977932fd96eaded52b32221.tar.gz
plugins/elements/: Allow file://localhost/foo/bar URLs and correctly fail for every other hostname that one sets. Thi...
Original commit message from CVS: reviewed by: Wim Taymans <wim@fluendo.com> * plugins/elements/gstfilesink.c: (gst_file_sink_uri_set_uri): * plugins/elements/gstfilesrc.c: (gst_file_src_uri_set_uri): Allow file://localhost/foo/bar URLs and correctly fail for every other hostname that one sets. This was gnomevfssrc is linked for those if installed as it can handle it (#403172)
Diffstat (limited to 'plugins')
-rw-r--r--plugins/elements/gstfilesink.c19
-rw-r--r--plugins/elements/gstfilesrc.c19
2 files changed, 36 insertions, 2 deletions
diff --git a/plugins/elements/gstfilesink.c b/plugins/elements/gstfilesink.c
index 25b854cad2..762121c148 100644
--- a/plugins/elements/gstfilesink.c
+++ b/plugins/elements/gstfilesink.c
@@ -542,7 +542,24 @@ gst_file_sink_uri_set_uri (GstURIHandler * handler, const gchar * uri)
return FALSE;
}
g_free (protocol);
- location = gst_uri_get_location (uri);
+
+ /* allow file://localhost/foo/bar by stripping localhost but fail
+ * for every other hostname */
+ if (g_str_has_prefix (uri, "file://localhost/")) {
+ char *tmp;
+
+ /* 16 == strlen ("file://localhost") */
+ tmp = g_strconcat ("file://", uri + 16, NULL);
+ /* we use gst_uri_get_location() although we already have the
+ * "location" with uri + 16 because it provides unescaping */
+ location = gst_uri_get_location (tmp);
+ g_free (tmp);
+ } else if (!g_str_has_prefix (uri, "file:///")) {
+ return FALSE;
+ } else {
+ location = gst_uri_get_location (uri);
+ }
+
ret = gst_file_sink_set_location (sink, location);
g_free (location);
diff --git a/plugins/elements/gstfilesrc.c b/plugins/elements/gstfilesrc.c
index f734d74edd..32f0f1e560 100644
--- a/plugins/elements/gstfilesrc.c
+++ b/plugins/elements/gstfilesrc.c
@@ -1062,7 +1062,24 @@ gst_file_src_uri_set_uri (GstURIHandler * handler, const gchar * uri)
return FALSE;
}
g_free (protocol);
- location = gst_uri_get_location (uri);
+
+ /* allow file://localhost/foo/bar by stripping localhost but fail
+ * for every other hostname */
+ if (g_str_has_prefix (uri, "file://localhost/")) {
+ char *tmp;
+
+ /* 16 == strlen ("file://localhost") */
+ tmp = g_strconcat ("file://", uri + 16, NULL);
+ /* we use gst_uri_get_location() although we already have the
+ * "location" with uri + 16 because it provides unescaping */
+ location = gst_uri_get_location (tmp);
+ g_free (tmp);
+ } else if (!g_str_has_prefix (uri, "file:///")) {
+ return FALSE;
+ } else {
+ location = gst_uri_get_location (uri);
+ }
+
ret = gst_file_src_set_location (src, location);
g_free (location);