mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-10-04 17:52:29 +00:00
playbin2: try to catch malformed URIs
Only log in debug log for now, since the check is a bit half-hearted, its purpose is mostly to make sure people use gst_filename_to_uri() or g_filename_to_uri(). https://bugzilla.gnome.org/show_bug.cgi?id=654673
This commit is contained in:
parent
454c554b11
commit
14a79628a7
1 changed files with 39 additions and 0 deletions
|
@ -1272,6 +1272,34 @@ gst_play_bin_finalize (GObject * object)
|
||||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gst_playbin_uri_is_valid (GstPlayBin * playbin, const gchar * uri)
|
||||||
|
{
|
||||||
|
const gchar *c;
|
||||||
|
|
||||||
|
GST_LOG_OBJECT (playbin, "checking uri '%s'", uri);
|
||||||
|
|
||||||
|
/* this just checks the protocol */
|
||||||
|
if (!gst_uri_is_valid (uri))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
for (c = uri; *c != '\0'; ++c) {
|
||||||
|
if (*c >= 128 || !g_ascii_isprint (*c))
|
||||||
|
goto invalid;
|
||||||
|
if (*c == ' ')
|
||||||
|
goto invalid;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
invalid:
|
||||||
|
{
|
||||||
|
GST_WARNING_OBJECT (playbin, "uri '%s' not valid, character #%u",
|
||||||
|
uri, (guint) ((guintptr) c - (guintptr) uri));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_play_bin_set_uri (GstPlayBin * playbin, const gchar * uri)
|
gst_play_bin_set_uri (GstPlayBin * playbin, const gchar * uri)
|
||||||
{
|
{
|
||||||
|
@ -1282,6 +1310,17 @@ gst_play_bin_set_uri (GstPlayBin * playbin, const gchar * uri)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!gst_playbin_uri_is_valid (playbin, uri)) {
|
||||||
|
if (g_str_has_prefix (uri, "file:")) {
|
||||||
|
GST_ERROR_OBJECT (playbin, "malformed file URI '%s' - make sure to "
|
||||||
|
"escape spaces and non-ASCII characters properly and specify an "
|
||||||
|
"absolute path. Use gst_filename_to_uri() to convert filenames "
|
||||||
|
"to URIs", uri);
|
||||||
|
} else {
|
||||||
|
GST_ERROR_OBJECT (playbin, "malformed URI '%s'", uri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GST_PLAY_BIN_LOCK (playbin);
|
GST_PLAY_BIN_LOCK (playbin);
|
||||||
group = playbin->next_group;
|
group = playbin->next_group;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue