/*** XDG MIME typefinder (to avoid false positives mostly) ***/
#ifdef USE_GIO
+static gboolean
+xdgmime_validate_name (const gchar * name)
+{
+ const gchar *s;
+
+ if (G_UNLIKELY (!g_ascii_isalpha (*name))) {
+ return FALSE;
+ }
+
+ /* FIXME: test name string more */
+ s = &name[1];
+ while (*s && (g_ascii_isalnum (*s) || strchr ("/-_.:+", *s) != NULL))
+ s++;
+ if (G_UNLIKELY (*s != '\0')) {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
static void
xdgmime_typefind (GstTypeFind * find, gpointer user_data)
{
return;
}
+ if (!xdgmime_validate_name (mimetype)) {
+ GST_LOG ("Ignoring mimetype with invalid structure name");
+ g_free (mimetype);
+ return;
+ }
+
/* Again, we mainly want the xdg typefinding to prevent false-positives on
* non-media formats, so suggest the type with a probability that trumps
* uncertain results of our typefinders, but not more than that. */