Fix #17661 exception on player

Problem with invalid characters in the file name. Strip them
and improve exception handling.