Changeset e22607b4b9712c117f394267d6631e5eef8d0e9b
- 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
| re148e58 |
re22607b |
|
| 799 | 799 | void filename_sanitize( char *str ) |
|---|
| 800 | 800 | { |
|---|
| | 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 | |
|---|
| 801 | 811 | while( *str ) |
|---|
| 802 | 812 | { |
|---|
| … | … | |
| 825 | 835 | void path_sanitize( char *str ) |
|---|
| 826 | 836 | { |
|---|
| | 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 | { |
|---|
| 827 | 844 | #ifdef WIN32 |
|---|
| 828 | | while( *str ) |
|---|
| 829 | | { |
|---|
| 830 | 845 | switch( *str ) |
|---|
| 831 | 846 | { |
|---|
| … | … | |
| 839 | 854 | *str = '_'; |
|---|
| 840 | 855 | } |
|---|
| | 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 |
|---|
| 841 | 876 | str++; |
|---|
| 842 | 877 | } |
|---|
| 843 | | #endif |
|---|
| 844 | | } |
|---|
| | 878 | } |
|---|