summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.com>2018-01-23 18:37:09 +0000
committerTim-Philipp Müller <tim@centricular.com>2018-01-23 18:38:26 +0000
commita5b5451d934e801e4a76a3803acc44b46a9afce7 (patch)
treed28c0942f021777a9eabae31df2177442bae34c4
parentdccfaf2e91a4a7b227d9193623344eb634aada5b (diff)
multifilesrc: fix up uri handler a little
Fix path escaping when creating URI from location in get_uri(). Return FALSE with an error when URI can't be parsed in set_uri(). https://bugzilla.gnome.org/show_bug.cgi?id=783581
-rw-r--r--gst/multifile/gstmultifilesrc.c46
1 files changed, 34 insertions, 12 deletions
diff --git a/gst/multifile/gstmultifilesrc.c b/gst/multifile/gstmultifilesrc.c
index 18ea59468..3ad1a1b88 100644
--- a/gst/multifile/gstmultifilesrc.c
+++ b/gst/multifile/gstmultifilesrc.c
@@ -508,10 +508,15 @@ gst_multi_file_src_uri_get_uri (GstURIHandler * handler)
gchar *ret;
GST_OBJECT_LOCK (src);
- if (src->filename != NULL)
- ret = g_strdup_printf ("multifile://%s", src->filename);
- else
+ if (src->filename != NULL) {
+ GstUri *uri = gst_uri_new ("multifle", NULL, NULL, GST_URI_NO_PORT,
+ src->filename, NULL, NULL);
+
+ ret = gst_uri_to_string (uri);
+ gst_uri_unref (uri);
+ } else {
ret = NULL;
+ }
GST_OBJECT_UNLOCK (src);
return ret;
@@ -522,20 +527,37 @@ gst_multi_file_src_uri_set_uri (GstURIHandler * handler, const gchar * uri,
GError ** error)
{
GstMultiFileSrc *src = GST_MULTI_FILE_SRC (handler);
-
GstUri *gsturi;
+ gchar *path;
gsturi = gst_uri_from_string (uri);
- g_free (src->filename);
- src->filename = NULL;
- if (gsturi) {
- gchar *turi = gst_uri_get_path (gsturi);
- gst_multi_file_src_set_location (src, turi);
- g_free (turi);
- gst_uri_unref (gsturi);
- }
+ if (gsturi == NULL)
+ goto invalid_uri;
+
+ /* This should get us the unescaped path */
+ path = gst_uri_get_path (gsturi);
+ if (path == NULL)
+ goto invalid_uri;
+
+ GST_OBJECT_LOCK (src);
+ gst_multi_file_src_set_location (src, path);
+ GST_OBJECT_UNLOCK (src);
+
+ g_free (path);
+ gst_uri_unref (gsturi);
return TRUE;
+
+/* ERRORS */
+invalid_uri:
+ {
+ GST_WARNING_OBJECT (src, "Invalid multifile URI '%s'", uri);
+ g_set_error (error, GST_URI_ERROR, GST_URI_ERROR_BAD_URI,
+ "Invalid multifile URI");
+ if (gsturi)
+ gst_uri_unref (gsturi);
+ return FALSE;
+ }
}
static void