Skip to content

Commit

Permalink
- Do not rewrite “+” as a white space when unescaping URL parameters …
Browse files Browse the repository at this point in the history
…(fixes #625).

- Rename decode_encoded_URI as unescape_URI as it really is what is done.
  • Loading branch information
Rémi Denis-Courmont committed Apr 3, 2006
1 parent a173024 commit a48f5f1
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 33 deletions.
3 changes: 0 additions & 3 deletions include/vlc_strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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( char *, convert_xml_special_chars, ( const char *psz_content ) );

Expand Down
12 changes: 6 additions & 6 deletions include/vlc_symbols.h
Original file line number Diff line number Diff line change
Expand Up @@ -480,9 +480,9 @@ struct module_symbols_t
double (*us_atof_inner) (const char *);
double (*us_strtod_inner) (const char *, char **);
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 * (*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);
char * (*FromUTF16_inner) (const uint16_t *);
const char * (*IsUTF8_inner) (const char *);
Expand Down Expand Up @@ -948,9 +948,9 @@ struct module_symbols_t
# define us_atof (p_symbols)->us_atof_inner
# define us_strtod (p_symbols)->us_strtod_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 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 FromUTF16 (p_symbols)->FromUTF16_inner
# define IsUTF8 (p_symbols)->IsUTF8_inner
Expand Down Expand Up @@ -1419,9 +1419,9 @@ struct module_symbols_t
((p_symbols)->us_atof_inner) = us_atof; \
((p_symbols)->us_strtod_inner) = us_strtod; \
((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)->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)->FromUTF16_inner) = FromUTF16; \
((p_symbols)->IsUTF8_inner) = IsUTF8; \
Expand Down
3 changes: 3 additions & 0 deletions include/vlc_url.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ static inline void vlc_UrlClean( vlc_url_t *url )
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 )
{
return ( (unsigned char)( c - 'a' ) < 26 )
Expand Down
2 changes: 0 additions & 2 deletions modules/control/http/http.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,6 @@ char *E_(ExtractURIValue)( char *psz_uri, const char *psz_name,
char *psz_value, int i_value_max );
/** \todo Describe this function */
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 */
playlist_item_t *E_(MRLParse)( intf_thread_t *, char *psz, char *psz_name );
Expand Down
14 changes: 7 additions & 7 deletions modules/control/http/macro.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ void E_(MacroDo)( httpd_file_sys_t *p_args,
{
char value[30];
E_(ExtractURIValue)( p_request, "seek_value", value, 30 );
E_(DecodeEncodedURI)( value );
unescape_URI( value );
E_(HandleSeek)( p_intf, value );
break;
}
Expand All @@ -248,7 +248,7 @@ void E_(MacroDo)( httpd_file_sys_t *p_args,

E_(ExtractURIValue)( p_request, "value", vol, 8 );
aout_VolumeGet( p_intf, &i_volume );
E_(DecodeEncodedURI)( vol );
unescape_URI( vol );

if( vol[0] == '+' )
{
Expand Down Expand Up @@ -305,9 +305,9 @@ void E_(MacroDo)( httpd_file_sys_t *p_args,
playlist_item_t *p_item;

E_(ExtractURIValue)( p_request, "mrl", mrl, 1024 );
E_(DecodeEncodedURI)( mrl );
unescape_URI( mrl );
E_(ExtractURIValue)( p_request, "name", psz_name, 1024 );
E_(DecodeEncodedURI)( psz_name );
unescape_URI( psz_name );
if( !*psz_name )
{
memcpy( psz_name, mrl, 1024 );
Expand Down Expand Up @@ -530,7 +530,7 @@ void E_(MacroDo)( httpd_file_sys_t *p_args,
char val[512];
E_(ExtractURIValue)( p_request,
vlm_properties[i], val, 512 );
E_(DecodeEncodedURI)( val );
unescape_URI( val );
if( strlen( val ) > 0 && i >= 4 )
{
p += sprintf( p, " %s %s", vlm_properties[i], val );
Expand Down Expand Up @@ -626,7 +626,7 @@ void E_(MacroDo)( httpd_file_sys_t *p_args,
if( p_intf->p_sys->p_vlm == NULL ) break;

E_(ExtractURIValue)( p_request, "file", file, 512 );
E_(DecodeEncodedURI)( file );
unescape_URI( file );

if( E_(StrToMacroType)( control ) == MVLC_VLM_LOAD )
sprintf( psz, "load %s", file );
Expand Down Expand Up @@ -661,7 +661,7 @@ void E_(MacroDo)( httpd_file_sys_t *p_args,
break;
}
E_(ExtractURIValue)( p_request, m->param1, value, 512 );
E_(DecodeEncodedURI)( value );
unescape_URI( value );

switch( E_(StrToMacroType)( m->param2 ) )
{
Expand Down
2 changes: 1 addition & 1 deletion modules/control/http/rpn.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ void E_(EvaluateRPN)( intf_thread_t *p_intf, mvar_t *vars,
char *tmp;

E_(ExtractURIValue)( url, name, value, 512 );
E_(DecodeEncodedURI)( value );
unescape_URI( value );
tmp = E_(FromUTF8)( p_intf, value );
E_(SSPush)( st, tmp );
free( tmp );
Expand Down
5 changes: 0 additions & 5 deletions modules/control/http/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -773,11 +773,6 @@ char *E_(ExtractURIValue)( char *psz_uri, const char *psz_name,
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
* permitted to have psz == new. new points to the first word of the
* string, the function returns the remaining string. */
Expand Down
2 changes: 1 addition & 1 deletion modules/demux/playlist/xspf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
char *psz_uri=NULL;
psz_uri = decode_encoded_URI_duplicate( psz_location );
psz_uri = unescape_URI_duplicate( psz_location );

if ( psz_uri )
{
Expand Down
15 changes: 7 additions & 8 deletions src/misc/strings.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,24 @@
#include <assert.h>

#include "vlc_strings.h"
#include "vlc_url.h"

/**
* Decode URI encoded string
* Unescape URI encoded 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 );
decode_encoded_URI( psz_dup );
unescape_URI( psz_dup );
return psz_dup;
}

/**
* Decode URI encoded string
* Unescape URI encoded string in place
* \return nothing
*/
void decode_encoded_URI( char *psz )
void unescape_URI( char *psz )
{
unsigned char *in = (unsigned char *)psz, *out = in, c;

Expand Down Expand Up @@ -101,9 +102,7 @@ void decode_encoded_URI( char *psz )
break;
}

case '+':
*out++ = ' ';
break;
/* + is not a special case - it means plus, not space. */

default:
/* Inserting non-ASCII or non-printable characters is unsafe,
Expand Down

0 comments on commit a48f5f1

Please sign in to comment.