Fix valid-path function.