$regex = array('#[^A-Za-z0-9:_\\\/-]#');
return preg_replace($regex, '', $path);
For general purpose use we need to be more permissive than that. Particularly, we should at least allow folder names with periods in them.
I think that makes sense Ian, are there any other characters that you think would be important to have? I mean ultimately the method is designed to provide a least common denominator across platforms for a safe path. That being said the colon is probably not a great thing to have in that character class anyway.
"." is used in front of a folder in linux to make it a hidden folder. I think that it isn't allowed to use the period, because the result of the name will depend on the OS. Can this be considered as a bug ?