diff options
author | Darren Salt <linux@youmustbejoking.demon.co.uk> | 2008-06-09 21:13:43 +0100 |
---|---|---|
committer | Darren Salt <linux@youmustbejoking.demon.co.uk> | 2008-06-09 21:13:43 +0100 |
commit | 089d7ce7450a4af86f2b6426b475a2da1d451a7d (patch) | |
tree | 12d3752bdd8a44665cfc4ce6bd444dbe22fe12dd | |
parent | 8b477584846b8086cb0423c91796830398099754 (diff) | |
download | xine-lib-089d7ce7450a4af86f2b6426b475a2da1d451a7d.tar.gz xine-lib-089d7ce7450a4af86f2b6426b475a2da1d451a7d.tar.bz2 |
Avoid false positives when looking up demuxer by MIME type.
These occur where the MIME type used as the key is a substring of a type in
some plugin's MIME type list but is not an exact match.
-rw-r--r-- | src/xine-engine/load_plugins.c | 39 |
1 files changed, 15 insertions, 24 deletions
diff --git a/src/xine-engine/load_plugins.c b/src/xine-engine/load_plugins.c index 107e7d792..031c94984 100644 --- a/src/xine-engine/load_plugins.c +++ b/src/xine-engine/load_plugins.c @@ -2519,47 +2519,38 @@ char *xine_get_demux_for_mime_type (xine_t *self, const char *mime_type) { plugin_catalog_t *catalog = self->plugin_catalog; plugin_node_t *node; char *id = NULL; - char *mime_arg, *mime_demux; - char *s; - const char *mt; int list_id, list_size; + const size_t mime_type_len = strlen (mime_type); - /* create a copy and convert to lower case */ - mime_arg = strdup(mime_type); - for(s=mime_arg; *s; s++) - *s = tolower(*s); - pthread_mutex_lock (&catalog->lock); list_size = xine_sarray_size (catalog->plugin_lists[PLUGIN_DEMUX - 1]); for (list_id = 0; (list_id < list_size) && !id; list_id++) { - demux_class_t *cls; node = xine_sarray_get (catalog->plugin_lists[PLUGIN_DEMUX - 1], list_id); if (node->plugin_class || _load_plugin_class(self, node, NULL)) { - cls = (demux_class_t *)node->plugin_class; - - mt = cls->get_mimetypes (cls); - if (mt) { - mime_demux = strdup(mt); - - for(s=mime_demux; *s; s++) - *s = tolower(*s); - - if( strstr(mime_demux, mime_arg) ) - id = strdup(node->info->id); - - free(mime_demux); + demux_class_t *cls = (demux_class_t *)node->plugin_class; + const char *mime = cls->get_mimetypes (cls); + while (mime) + { + while (*mime == ';' || isspace (*mime)) + ++mime; + if (!strncmp (mime, mime_type, mime_type_len) && + (!mime[mime_type_len] || mime[mime_type_len] == ':' || mime[mime_type_len] == ';')) + { + free (id); + id = strdup(node->info->id); + break; + } + mime = strchr (mime, ';'); } } } pthread_mutex_unlock (&catalog->lock); - free(mime_arg); - return id; } |