Commit a48f5f17 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

- Do not rewrite “+” as a white space when unescaping URL parameters (fixes #625).

- Rename decode_encoded_URI as unescape_URI as it really is what is done.
parent a1730242
...@@ -31,9 +31,6 @@ ...@@ -31,9 +31,6 @@
* @{ * @{
*/ */
VLC_EXPORT( char *, decode_encoded_URI_duplicate, ( const char *psz ) );
VLC_EXPORT( void, decode_encoded_URI, ( char *psz ) );
VLC_EXPORT( void, resolve_xml_special_chars, ( char *psz_value ) ); VLC_EXPORT( void, resolve_xml_special_chars, ( char *psz_value ) );
VLC_EXPORT( char *, convert_xml_special_chars, ( const char *psz_content ) ); VLC_EXPORT( char *, convert_xml_special_chars, ( const char *psz_content ) );
......
...@@ -480,9 +480,9 @@ struct module_symbols_t ...@@ -480,9 +480,9 @@ struct module_symbols_t
double (*us_atof_inner) (const char *); double (*us_atof_inner) (const char *);
double (*us_strtod_inner) (const char *, char **); double (*us_strtod_inner) (const char *, char **);
lldiv_t (*vlc_lldiv_inner) (long long numer, long long denom); lldiv_t (*vlc_lldiv_inner) (long long numer, long long denom);
void (*decode_encoded_URI_inner) (char *psz); void (*unescape_URI_inner) (char *psz);
char * (*convert_xml_special_chars_inner) (const char *psz_content); char * (*convert_xml_special_chars_inner) (const char *psz_content);
char * (*decode_encoded_URI_duplicate_inner) (const char *psz); char * (*unescape_URI_duplicate_inner) (const char *psz);
void (*resolve_xml_special_chars_inner) (char *psz_value); void (*resolve_xml_special_chars_inner) (char *psz_value);
char * (*FromUTF16_inner) (const uint16_t *); char * (*FromUTF16_inner) (const uint16_t *);
const char * (*IsUTF8_inner) (const char *); const char * (*IsUTF8_inner) (const char *);
...@@ -948,9 +948,9 @@ struct module_symbols_t ...@@ -948,9 +948,9 @@ struct module_symbols_t
# define us_atof (p_symbols)->us_atof_inner # define us_atof (p_symbols)->us_atof_inner
# define us_strtod (p_symbols)->us_strtod_inner # define us_strtod (p_symbols)->us_strtod_inner
# define vlc_lldiv (p_symbols)->vlc_lldiv_inner # define vlc_lldiv (p_symbols)->vlc_lldiv_inner
# define decode_encoded_URI (p_symbols)->decode_encoded_URI_inner # define unescape_URI (p_symbols)->unescape_URI_inner
# define convert_xml_special_chars (p_symbols)->convert_xml_special_chars_inner # define convert_xml_special_chars (p_symbols)->convert_xml_special_chars_inner
# define decode_encoded_URI_duplicate (p_symbols)->decode_encoded_URI_duplicate_inner # define unescape_URI_duplicate (p_symbols)->unescape_URI_duplicate_inner
# define resolve_xml_special_chars (p_symbols)->resolve_xml_special_chars_inner # define resolve_xml_special_chars (p_symbols)->resolve_xml_special_chars_inner
# define FromUTF16 (p_symbols)->FromUTF16_inner # define FromUTF16 (p_symbols)->FromUTF16_inner
# define IsUTF8 (p_symbols)->IsUTF8_inner # define IsUTF8 (p_symbols)->IsUTF8_inner
...@@ -1419,9 +1419,9 @@ struct module_symbols_t ...@@ -1419,9 +1419,9 @@ struct module_symbols_t
((p_symbols)->us_atof_inner) = us_atof; \ ((p_symbols)->us_atof_inner) = us_atof; \
((p_symbols)->us_strtod_inner) = us_strtod; \ ((p_symbols)->us_strtod_inner) = us_strtod; \
((p_symbols)->vlc_lldiv_inner) = vlc_lldiv; \ ((p_symbols)->vlc_lldiv_inner) = vlc_lldiv; \
((p_symbols)->decode_encoded_URI_inner) = decode_encoded_URI; \ ((p_symbols)->unescape_URI_inner) = unescape_URI; \
((p_symbols)->convert_xml_special_chars_inner) = convert_xml_special_chars; \ ((p_symbols)->convert_xml_special_chars_inner) = convert_xml_special_chars; \
((p_symbols)->decode_encoded_URI_duplicate_inner) = decode_encoded_URI_duplicate; \ ((p_symbols)->unescape_URI_duplicate_inner) = unescape_URI_duplicate; \
((p_symbols)->resolve_xml_special_chars_inner) = resolve_xml_special_chars; \ ((p_symbols)->resolve_xml_special_chars_inner) = resolve_xml_special_chars; \
((p_symbols)->FromUTF16_inner) = FromUTF16; \ ((p_symbols)->FromUTF16_inner) = FromUTF16; \
((p_symbols)->IsUTF8_inner) = IsUTF8; \ ((p_symbols)->IsUTF8_inner) = IsUTF8; \
......
...@@ -169,6 +169,9 @@ static inline void vlc_UrlClean( vlc_url_t *url ) ...@@ -169,6 +169,9 @@ static inline void vlc_UrlClean( vlc_url_t *url )
url->psz_buffer = NULL; url->psz_buffer = NULL;
} }
VLC_EXPORT( char *, unescape_URI_duplicate, ( const char *psz ) );
VLC_EXPORT( void, unescape_URI, ( char *psz ) );
static inline int isurlsafe( int c ) static inline int isurlsafe( int c )
{ {
return ( (unsigned char)( c - 'a' ) < 26 ) return ( (unsigned char)( c - 'a' ) < 26 )
......
...@@ -128,8 +128,6 @@ char *E_(ExtractURIValue)( char *psz_uri, const char *psz_name, ...@@ -128,8 +128,6 @@ char *E_(ExtractURIValue)( char *psz_uri, const char *psz_name,
char *psz_value, int i_value_max ); char *psz_value, int i_value_max );
/** \todo Describe this function */ /** \todo Describe this function */
int E_(TestURIParam)( char *psz_uri, const char *psz_name ); int E_(TestURIParam)( char *psz_uri, const char *psz_name );
/** This function extracts the original value from an URL-encoded string */
void E_(DecodeEncodedURI)( char *psz );
/** This function parses a MRL */ /** This function parses a MRL */
playlist_item_t *E_(MRLParse)( intf_thread_t *, char *psz, char *psz_name ); playlist_item_t *E_(MRLParse)( intf_thread_t *, char *psz, char *psz_name );
......
...@@ -236,7 +236,7 @@ void E_(MacroDo)( httpd_file_sys_t *p_args, ...@@ -236,7 +236,7 @@ void E_(MacroDo)( httpd_file_sys_t *p_args,
{ {
char value[30]; char value[30];
E_(ExtractURIValue)( p_request, "seek_value", value, 30 ); E_(ExtractURIValue)( p_request, "seek_value", value, 30 );
E_(DecodeEncodedURI)( value ); unescape_URI( value );
E_(HandleSeek)( p_intf, value ); E_(HandleSeek)( p_intf, value );
break; break;
} }
...@@ -248,7 +248,7 @@ void E_(MacroDo)( httpd_file_sys_t *p_args, ...@@ -248,7 +248,7 @@ void E_(MacroDo)( httpd_file_sys_t *p_args,
E_(ExtractURIValue)( p_request, "value", vol, 8 ); E_(ExtractURIValue)( p_request, "value", vol, 8 );
aout_VolumeGet( p_intf, &i_volume ); aout_VolumeGet( p_intf, &i_volume );
E_(DecodeEncodedURI)( vol ); unescape_URI( vol );
if( vol[0] == '+' ) if( vol[0] == '+' )
{ {
...@@ -305,9 +305,9 @@ void E_(MacroDo)( httpd_file_sys_t *p_args, ...@@ -305,9 +305,9 @@ void E_(MacroDo)( httpd_file_sys_t *p_args,
playlist_item_t *p_item; playlist_item_t *p_item;
E_(ExtractURIValue)( p_request, "mrl", mrl, 1024 ); E_(ExtractURIValue)( p_request, "mrl", mrl, 1024 );
E_(DecodeEncodedURI)( mrl ); unescape_URI( mrl );
E_(ExtractURIValue)( p_request, "name", psz_name, 1024 ); E_(ExtractURIValue)( p_request, "name", psz_name, 1024 );
E_(DecodeEncodedURI)( psz_name ); unescape_URI( psz_name );
if( !*psz_name ) if( !*psz_name )
{ {
memcpy( psz_name, mrl, 1024 ); memcpy( psz_name, mrl, 1024 );
...@@ -530,7 +530,7 @@ void E_(MacroDo)( httpd_file_sys_t *p_args, ...@@ -530,7 +530,7 @@ void E_(MacroDo)( httpd_file_sys_t *p_args,
char val[512]; char val[512];
E_(ExtractURIValue)( p_request, E_(ExtractURIValue)( p_request,
vlm_properties[i], val, 512 ); vlm_properties[i], val, 512 );
E_(DecodeEncodedURI)( val ); unescape_URI( val );
if( strlen( val ) > 0 && i >= 4 ) if( strlen( val ) > 0 && i >= 4 )
{ {
p += sprintf( p, " %s %s", vlm_properties[i], val ); p += sprintf( p, " %s %s", vlm_properties[i], val );
...@@ -626,7 +626,7 @@ void E_(MacroDo)( httpd_file_sys_t *p_args, ...@@ -626,7 +626,7 @@ void E_(MacroDo)( httpd_file_sys_t *p_args,
if( p_intf->p_sys->p_vlm == NULL ) break; if( p_intf->p_sys->p_vlm == NULL ) break;
E_(ExtractURIValue)( p_request, "file", file, 512 ); E_(ExtractURIValue)( p_request, "file", file, 512 );
E_(DecodeEncodedURI)( file ); unescape_URI( file );
if( E_(StrToMacroType)( control ) == MVLC_VLM_LOAD ) if( E_(StrToMacroType)( control ) == MVLC_VLM_LOAD )
sprintf( psz, "load %s", file ); sprintf( psz, "load %s", file );
...@@ -661,7 +661,7 @@ void E_(MacroDo)( httpd_file_sys_t *p_args, ...@@ -661,7 +661,7 @@ void E_(MacroDo)( httpd_file_sys_t *p_args,
break; break;
} }
E_(ExtractURIValue)( p_request, m->param1, value, 512 ); E_(ExtractURIValue)( p_request, m->param1, value, 512 );
E_(DecodeEncodedURI)( value ); unescape_URI( value );
switch( E_(StrToMacroType)( m->param2 ) ) switch( E_(StrToMacroType)( m->param2 ) )
{ {
......
...@@ -353,7 +353,7 @@ void E_(EvaluateRPN)( intf_thread_t *p_intf, mvar_t *vars, ...@@ -353,7 +353,7 @@ void E_(EvaluateRPN)( intf_thread_t *p_intf, mvar_t *vars,
char *tmp; char *tmp;
E_(ExtractURIValue)( url, name, value, 512 ); E_(ExtractURIValue)( url, name, value, 512 );
E_(DecodeEncodedURI)( value ); unescape_URI( value );
tmp = E_(FromUTF8)( p_intf, value ); tmp = E_(FromUTF8)( p_intf, value );
E_(SSPush)( st, tmp ); E_(SSPush)( st, tmp );
free( tmp ); free( tmp );
......
...@@ -773,11 +773,6 @@ char *E_(ExtractURIValue)( char *psz_uri, const char *psz_name, ...@@ -773,11 +773,6 @@ char *E_(ExtractURIValue)( char *psz_uri, const char *psz_name,
return p; return p;
} }
void E_(DecodeEncodedURI)( char *psz )
{
decode_encoded_URI( psz );
}
/* Since the resulting string is smaller we can work in place, so it is /* Since the resulting string is smaller we can work in place, so it is
* permitted to have psz == new. new points to the first word of the * permitted to have psz == new. new points to the first word of the
* string, the function returns the remaining string. */ * string, the function returns the remaining string. */
......
...@@ -659,7 +659,7 @@ static vlc_bool_t insert_new_item( playlist_t *p_pl, playlist_item_t *p_cur, ...@@ -659,7 +659,7 @@ static vlc_bool_t insert_new_item( playlist_t *p_pl, playlist_item_t *p_cur,
playlist_item_t **pp_new, char *psz_location ) playlist_item_t **pp_new, char *psz_location )
{ {
char *psz_uri=NULL; char *psz_uri=NULL;
psz_uri = decode_encoded_URI_duplicate( psz_location ); psz_uri = unescape_URI_duplicate( psz_location );
if ( psz_uri ) if ( psz_uri )
{ {
......
...@@ -33,23 +33,24 @@ ...@@ -33,23 +33,24 @@
#include <assert.h> #include <assert.h>
#include "vlc_strings.h" #include "vlc_strings.h"
#include "vlc_url.h"
/** /**
* Decode URI encoded string * Unescape URI encoded string
* \return decoded duplicated string * \return decoded duplicated string
*/ */
char *decode_encoded_URI_duplicate( const char *psz ) char *unescape_URI_duplicate( const char *psz )
{ {
char *psz_dup = strdup( psz ); char *psz_dup = strdup( psz );
decode_encoded_URI( psz_dup ); unescape_URI( psz_dup );
return psz_dup; return psz_dup;
} }
/** /**
* Decode URI encoded string * Unescape URI encoded string in place
* \return nothing * \return nothing
*/ */
void decode_encoded_URI( char *psz ) void unescape_URI( char *psz )
{ {
unsigned char *in = (unsigned char *)psz, *out = in, c; unsigned char *in = (unsigned char *)psz, *out = in, c;
...@@ -101,9 +102,7 @@ void decode_encoded_URI( char *psz ) ...@@ -101,9 +102,7 @@ void decode_encoded_URI( char *psz )
break; break;
} }
case '+': /* + is not a special case - it means plus, not space. */
*out++ = ' ';
break;
default: default:
/* Inserting non-ASCII or non-printable characters is unsafe, /* Inserting non-ASCII or non-printable characters is unsafe,
......
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