Commit e22607b4 authored by Antoine Cellerier's avatar Antoine Cellerier

Don't authorize "." or ".." for filenames.

parent 512f81c7
...@@ -798,6 +798,16 @@ char *__str_format( vlc_object_t *p_this, const char *psz_src ) ...@@ -798,6 +798,16 @@ char *__str_format( vlc_object_t *p_this, const char *psz_src )
*/ */
void filename_sanitize( char *str ) void filename_sanitize( char *str )
{ {
if( *str == '.' && (str[1] == '\0' || (str[1] == '.' && str[2] == '\0' ) ) )
{
while( *str )
{
*str = '_';
str++;
}
return;
}
while( *str ) while( *str )
{ {
switch( *str ) switch( *str )
...@@ -824,9 +834,14 @@ void filename_sanitize( char *str ) ...@@ -824,9 +834,14 @@ void filename_sanitize( char *str )
*/ */
void path_sanitize( char *str ) void path_sanitize( char *str )
{ {
#ifdef WIN32 #if 0
Uncomment the two blocks to prevent /../ or /./, i'm not sure that we
want to.
char *prev = str - 1;
#endif
while( *str ) while( *str )
{ {
#ifdef WIN32
switch( *str ) switch( *str )
{ {
case '*': case '*':
...@@ -838,7 +853,26 @@ void path_sanitize( char *str ) ...@@ -838,7 +853,26 @@ void path_sanitize( char *str )
case '>': case '>':
*str = '_'; *str = '_';
} }
str++; #endif
#if 0
if( *str == '/'
#ifdef WIN32
|| *str == '\\'
#endif
)
{
if( str - prev == 2 && prev[1] == '.' )
{
prev[1] = '.';
}
else if( str - prev == 3 && prev[1] == '.' && prev[2] == '.' )
{
prev[1] = '_';
prev[2] = '_';
}
prev = str;
} }
#endif #endif
str++;
}
} }
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