From a5b5451d934e801e4a76a3803acc44b46a9afce7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Tue, 23 Jan 2018 18:37:09 +0000 Subject: [PATCH] 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 --- gst/multifile/gstmultifilesrc.c | 46 ++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/gst/multifile/gstmultifilesrc.c b/gst/multifile/gstmultifilesrc.c index 18ea594681..3ad1a1b88d 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