Improved invalid file chars handling