Commit ae074ecf authored by Laurent Aimar's avatar Laurent Aimar

* input: if we failed to open the file, and the name has a '%', we

decode it as a url encoded one and we retry.
 (Btw, this will break playing of paths that have '%' and ':' )
parent 5bbca7b8
......@@ -56,13 +56,14 @@ struct input_thread_sys_t
int64_t i_stop_time;
};
static int RunThread ( input_thread_t *p_input );
static int InitThread ( input_thread_t *p_input );
static void ErrorThread ( input_thread_t *p_input );
static void EndThread ( input_thread_t *p_input );
static int RunThread ( input_thread_t *p_input );
static int InitThread ( input_thread_t *p_input );
static void ErrorThread( input_thread_t *p_input );
static void EndThread ( input_thread_t *p_input );
static void ParseOption ( input_thread_t *p_input,
const char *psz_option );
static void ParseOption( input_thread_t *p_input, const char *psz_option );
static void DecodeUrl ( char * );
/*****************************************************************************
* Callbacks
......@@ -753,6 +754,15 @@ static int InitThread( input_thread_t * p_input )
p_input->p_access = module_Need( p_input, "access",
p_input->psz_access, VLC_TRUE );
/* Maybe we had an encoded url */
if( !p_input->p_access && strchr( p_input->psz_name, '%' ) )
{
DecodeUrl( p_input->psz_name );
msg_Dbg( p_input, "retying with %s", p_input->psz_name );
p_input->p_access = module_Need( p_input, "access",
p_input->psz_access, VLC_TRUE );
}
#ifndef WIN32 /* Remove this gross hack from the win32 build as colons
* are forbidden in filenames on Win32. */
......@@ -769,7 +779,6 @@ static int InitThread( input_thread_t * p_input )
p_input->psz_access, VLC_TRUE );
}
#endif
if( p_input->p_access == NULL )
{
msg_Err( p_input, "no suitable access module for `%s/%s://%s'",
......@@ -1231,6 +1240,44 @@ static void EndThread( input_thread_t * p_input )
/* Tell we're dead */
p_input->b_dead = 1;
}
/*****************************************************************************
* DecodeUrl: decode a given encoded url
*****************************************************************************/
static void DecodeUrl( char *psz )
{
char *dup = strdup( psz );
char *p = dup;
while( *p )
{
if( *p == '%' )
{
char val[3];
p++;
if( !*p )
{
break;
}
val[0] = *p++;
val[1] = *p++;
val[2] = '\0';
*psz++ = strtol( val, NULL, 16 );
}
else if( *p == '+' )
{
*psz++ = ' ';
p++;
}
else
{
*psz++ = *p++;
}
}
*psz++ ='\0';
free( dup );
}
/*****************************************************************************
* ParseOption: parses the options for the input
......
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