Changeset e22607b4b9712c117f394267d6631e5eef8d0e9b

Show
Ignore:
Timestamp:
03/02/07 22:00:22 (1 year ago)
Author:
Antoine Cellerier <dionoea@videolan.org>
git-committer:
Antoine Cellerier <dionoea@videolan.org> 1172869222 +0000
git-parent:

[512f81c76f0e1e3253ccca718169c6d1f0a8f318]

git-author:
Antoine Cellerier <dionoea@videolan.org> 1172869222 +0000
Message:

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

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/text/strings.c

    re148e58 re22607b  
    799799void filename_sanitize( char *str ) 
    800800{ 
     801    if( *str == '.' && (str[1] == '\0' || (str[1] == '.' && str[2] == '\0' ) ) ) 
     802    { 
     803        while( *str ) 
     804        { 
     805            *str = '_'; 
     806            str++; 
     807        } 
     808        return; 
     809    } 
     810 
    801811    while( *str ) 
    802812    { 
     
    825835void path_sanitize( char *str ) 
    826836{ 
     837#if 0 
     838    Uncomment the two blocks to prevent /../ or /./, i'm not sure that we 
     839    want to. 
     840    char *prev = str - 1; 
     841#endif 
     842    while( *str ) 
     843    { 
    827844#ifdef WIN32 
    828     while( *str ) 
    829     { 
    830845        switch( *str ) 
    831846        { 
     
    839854                *str = '_'; 
    840855        } 
     856#endif 
     857#if 0 
     858        if( *str == '/' 
     859#ifdef WIN32 
     860            || *str == '\\' 
     861#endif 
     862            ) 
     863        { 
     864            if( str - prev == 2 && prev[1] == '.' ) 
     865            { 
     866                prev[1] = '.'; 
     867            } 
     868            else if( str - prev == 3 && prev[1] == '.' && prev[2] == '.' ) 
     869            { 
     870                prev[1] = '_'; 
     871                prev[2] = '_'; 
     872            } 
     873            prev = str; 
     874        } 
     875#endif 
    841876        str++; 
    842877    } 
    843 #endif 
    844 
     878