I would like to normalize a path from an external resource to prevent directory traversal attacks. I know about the realpath() function, but sadly this function returns only the path of existing directories. So if the directory doesn't exist (yet) the realpath() function cuts off the whole part of the path which doesn't exist.
So my Question is: Do you know a PHP function which only normalizes the path?
PS: I also don't want to create all possible directories in advance ;-)