improved sanitizing of path string