I am to generate a file name that will be used for a ZIP file sent back to the user from a web app. I have no idea what OS that file will ultimately be saved to so I have to come up with a way to sanitise that file name on miltiple plateform (at the very least, it must be safe on Windows, Linux and Mac). The file name comes from a user-supplied field (stored as UTF-16) and I would like to keep the original text as much as possible. Audience is global so I do not see a way to limit the allowed characters to a simple set.
If there a safe strategy for such an operation ? If it helps, the software is written in C# and runs on both windows and linux servers.
Surprisingly, I cannot seem to find a proper way to do this: all methods I found are either specific to the OS the software runs on, use a limited list of invalid chars (only the most obvious ones) or use a whitelist.