This regexp is duplicated many times. Suggest writing a single function to sanitize filenames and reusing it.