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

Stricter RFC1788 obeying UrlEncode

parent fd014e1e
......@@ -222,19 +222,23 @@ static inline void vlc_UrlClean( vlc_url_t *url )
static inline char *vlc_UrlEncode( const char *psz_url )
{
char *psz_enc, *out;
const char *in;
const unsigned char *in;
psz_enc = (char *)malloc( 3 * strlen( psz_url ) + 1 );
if( psz_enc == NULL )
return NULL;
out = psz_enc;
for( in = psz_url; *in; in++ )
for( in = (const unsigned char *)psz_url; *in; in++ )
{
unsigned char c = *(unsigned char *)in;
unsigned char c = *in;
if( ( c <= 32 ) || ( c == '%' ) || ( c == '?' ) || ( c == '&' )
|| ( c == '+' ) || ( c >= 128 ) )
if( ( (unsigned char)( c - 'a' ) < 26 )
|| ( (unsigned char)( c - 'A' ) < 26 )
|| ( (unsigned char)( c - '9' ) < 10 )
|| strchr( "$-_.+!*'(),", c ) != NULL )
*out++ = (char)c;
else
{
*out++ = '%';
*out++ = ( ( c >> 4 ) >= 0xA ) ? 'A' + ( c >> 4 ) - 0xA
......@@ -242,8 +246,6 @@ static inline char *vlc_UrlEncode( const char *psz_url )
*out++ = ( ( c & 0xf ) >= 0xA ) ? 'A' + ( c & 0xf ) - 0xA
: '0' + ( c & 0xf );
}
else
*out++ = (char)c;
}
*out++ = '\0';
......
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