invalid file name chars
BlitzMax Forums/BlitzMax Programming/invalid file name chars
| ||
| Hi, I've banned the following characters from file names: "|*\/:;~?<> But can you think of any more that might screw things up, especially for non-english keyboard layouts? Thanks. |
| ||
The plus sign "+" could mess things up too; it's supported through the windows command line as a way to join files.
C:\>copy b.txt+c.txt a.txt
b.txt
c.txt
1 file(s) copied.
Other characters not supported by windows include the comma "," and the equals "=" You should also watch out for the "%" sign because this is used to reference variables. Consider the following:
C:\>echo Hello > %PROMPT%.txt
C:\>dir *.txt
Volume in drive C is Sys
Volume Serial Number is B84E-DC4E
Directory of C:\
03/10/2007 14:58 8 $P$G.txt
11 File(s) 8 bytes
0 Dir(s) 147,663,589,376 bytes free
|
| ||
| Thanks I forgot about batch file stuff, will add +,=% :-) |
| ||
| >>non-english keyboard layouts? Gery, in my experience I have a BIG issue when using European characters, that'll cause Chinese/Japanese/Korean OSes fail to load file. (Just happened when I play TECNO and I contacted auther for solution) If the requirements is "stable on all possible OSes", alphabet chars, numbers and "_" are safer. |
| ||
| Can you elaborate yoko? thx. |
| ||
| If you're going for maximum stability and security, you should white list the characters you want to allow rather than black list the ones you want to deny. I'd suggest: A-Z a-z 0-9 - _ Also, and I'm sure you know this but others reading the thread might not, keep in mind that some OSes have case-sensitive file names, so ABCD.txt and abcd.txt could be different files. |
| ||
| yep thanks. whitelist could be the way to go I just though I might let the players have some freedom of expression in their names which get turned into filenames. |
| ||
| It really depends on how much security and stability you need for your app. If you're doing a web application, I would definitely white list, since otherwise it could be open to remote attacks. If you're making a single player game, a black list of the characters mentioned by you and others above would probably suffice. |