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
This commit is contained in:
Tim-Philipp Müller 2018-01-23 18:37:09 +00:00
parent dccfaf2e91
commit a5b5451d93

View file

@ -508,10 +508,15 @@ gst_multi_file_src_uri_get_uri (GstURIHandler * handler)
gchar *ret; gchar *ret;
GST_OBJECT_LOCK (src); GST_OBJECT_LOCK (src);
if (src->filename != NULL) if (src->filename != NULL) {
ret = g_strdup_printf ("multifile://%s", src->filename); GstUri *uri = gst_uri_new ("multifle", NULL, NULL, GST_URI_NO_PORT,
else src->filename, NULL, NULL);
ret = gst_uri_to_string (uri);
gst_uri_unref (uri);
} else {
ret = NULL; ret = NULL;
}
GST_OBJECT_UNLOCK (src); GST_OBJECT_UNLOCK (src);
return ret; return ret;
@ -522,20 +527,37 @@ gst_multi_file_src_uri_set_uri (GstURIHandler * handler, const gchar * uri,
GError ** error) GError ** error)
{ {
GstMultiFileSrc *src = GST_MULTI_FILE_SRC (handler); GstMultiFileSrc *src = GST_MULTI_FILE_SRC (handler);
GstUri *gsturi; GstUri *gsturi;
gchar *path;
gsturi = gst_uri_from_string (uri); gsturi = gst_uri_from_string (uri);
g_free (src->filename); if (gsturi == NULL)
src->filename = NULL; goto invalid_uri;
if (gsturi) {
gchar *turi = gst_uri_get_path (gsturi); /* This should get us the unescaped path */
gst_multi_file_src_set_location (src, turi); path = gst_uri_get_path (gsturi);
g_free (turi); if (path == NULL)
gst_uri_unref (gsturi); 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; 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 static void