Commit dc39e0ea authored by Thomas Guillem's avatar Thomas Guillem

demux/playlist: ensure that a playlist is a file

A lot of playlist probe only check the file extension that returns true for a
directory too.
parent 9acc7735
......@@ -145,6 +145,7 @@ int Import_ASX( vlc_object_t *p_this )
{
demux_t *p_demux = (demux_t *)p_this;
CHECK_FILE();
if( demux_IsPathExtension( p_demux, ".asx" ) ||
demux_IsPathExtension( p_demux, ".wax" ) ||
demux_IsPathExtension( p_demux, ".wvx" ) ||
......
......@@ -49,6 +49,7 @@ int Import_B4S( vlc_object_t *p_this )
{
demux_t *demux = (demux_t *)p_this;
CHECK_FILE();
if( !demux_IsPathExtension( demux, ".b4s" )
&& !demux_IsForced( demux, "b4s-open" ) )
return VLC_EGENERIC;
......
......@@ -42,10 +42,11 @@ static int Demux(demux_t *);
static input_item_t *ParseLine(char *line);
/** Detect dvb-utils zap channels.conf format */
int Import_DVB(vlc_object_t *obj)
int Import_DVB(vlc_object_t *p_this)
{
demux_t *demux = (demux_t *)obj;
demux_t *demux = (demux_t *)p_this;
CHECK_FILE();
if (!demux_IsPathExtension(demux, ".conf" ) && !demux->b_force )
return VLC_EGENERIC;
......
......@@ -73,6 +73,7 @@ int Import_GVP( vlc_object_t *p_this )
int i_peek, i, b_found = false;
const uint8_t *p_peek;
CHECK_FILE();
i_peek = stream_Peek( p_demux->s, &p_peek, MAX_LINE );
for( i = 0; i < i_peek - (int)sizeof("gvp_version:"); i++ )
......
......@@ -47,6 +47,7 @@ int Import_IFO( vlc_object_t *p_this )
{
demux_t *p_demux = (demux_t *)p_this;
CHECK_FILE();
if( !p_demux->psz_file )
return VLC_EGENERIC;
......
......@@ -69,6 +69,7 @@ int Import_M3U( vlc_object_t *p_this )
char *(*pf_dup) (const char *) = GuessEncoding;
int offset = 0;
CHECK_FILE();
if( stream_Peek( p_demux->s, &p_peek, 3 ) == 3
&& !memcmp( p_peek, "\xef\xbb\xbf", 3) )
{
......
......@@ -82,24 +82,34 @@ extern input_item_t * GetCurrentItem(demux_t *p_demux);
bool CheckContentType( stream_t * p_stream, const char * psz_ctype );
#define CHECK_FILE() do { \
bool b_is_dir = false; \
stream_Control( ((demux_t *)p_this)->s, STREAM_IS_DIRECTORY, &b_is_dir ); \
if( b_is_dir ) \
return VLC_EGENERIC; \
} while(0)
#define STANDARD_DEMUX_INIT_MSG( msg ) do { \
DEMUX_INIT_COMMON(); \
msg_Dbg( p_demux, "%s", msg ); } while(0)
#define DEMUX_BY_EXTENSION_MSG( ext, msg ) \
demux_t *p_demux = (demux_t *)p_this; \
CHECK_FILE(); \
if( !demux_IsPathExtension( p_demux, ext ) ) \
return VLC_EGENERIC; \
STANDARD_DEMUX_INIT_MSG( msg );
#define DEMUX_BY_EXTENSION_OR_FORCED_MSG( ext, module, msg ) \
demux_t *p_demux = (demux_t *)p_this; \
CHECK_FILE(); \
if( !demux_IsPathExtension( p_demux, ext ) && !demux_IsForced( p_demux, module ) ) \
return VLC_EGENERIC; \
STANDARD_DEMUX_INIT_MSG( msg );
#define DEMUX_BY_EXTENSION_OR_MIMETYPE( ext, mime, msg ) \
demux_t *p_demux = (demux_t *)p_this; \
CHECK_FILE(); \
char* demux_mimetype = stream_ContentType( p_demux->s ); \
if(!( demux_IsPathExtension( p_demux, ext ) || (demux_mimetype && !strcasecmp( mime, demux_mimetype )) )) { \
free( demux_mimetype ); \
......
......@@ -51,6 +51,7 @@ int Import_PLS( vlc_object_t *p_this )
{
demux_t *p_demux = (demux_t *)p_this;
const uint8_t *p_peek;
CHECK_FILE();
CHECK_PEEK( p_peek, 10 );
if( POKE( p_peek, "[playlist]", 10 ) || POKE( p_peek, "[Reference]", 10 ) ||
......
......@@ -48,6 +48,7 @@ int Import_podcast( vlc_object_t *p_this )
{
demux_t *p_demux = (demux_t *)p_this;
CHECK_FILE();
if( !demux_IsForced( p_demux, "podcast" ) )
return VLC_EGENERIC;
......
......@@ -82,6 +82,7 @@ int Import_QTL( vlc_object_t *p_this )
{
demux_t *p_demux = (demux_t *)p_this;
CHECK_FILE();
if( !demux_IsPathExtension( p_demux, ".qtl" ) )
return VLC_EGENERIC;
......
......@@ -79,6 +79,7 @@ int Import_RAM( vlc_object_t *p_this )
demux_t *p_demux = (demux_t *)p_this;
const uint8_t *p_peek;
CHECK_FILE();
if(! demux_IsPathExtension( p_demux, ".ram" ) ||
demux_IsPathExtension( p_demux, ".rm" ) )
return VLC_EGENERIC;
......
......@@ -140,6 +140,7 @@ int Import_SGIMB( vlc_object_t * p_this )
const uint8_t *p_peek;
int i_size;
CHECK_FILE();
/* Lets check the content to see if this is a sgi mediabase file */
i_size = stream_Peek( p_demux->s, &p_peek, MAX_LINE );
i_size -= sizeof("sgiNameServerHost=") - 1;
......
......@@ -59,6 +59,7 @@ int Import_Shoutcast( vlc_object_t *p_this )
{
demux_t *p_demux = (demux_t *)p_this;
CHECK_FILE();
if( !demux_IsForced( p_demux, "shout-winamp" ) )
return VLC_EGENERIC;
......
......@@ -172,6 +172,8 @@ void Close_WPL( vlc_object_t* p_this )
int Import_WPL( vlc_object_t* p_this )
{
demux_t* p_demux = (demux_t*)p_this;
CHECK_FILE();
if( !demux_IsPathExtension( p_demux, ".wpl" ) &&
!demux_IsPathExtension( p_demux, ".zpl" ) )
return VLC_EGENERIC;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment