Is there a way to turn arbitrary user input names into safe filenames with an encoding that is reversible?
I have some data files that belong to entities that users named. Of course, they can do silly things like put invalid filesystem characters in their names.
The two suggestions I see frequently for this are:
A) Base64 encode them
B) Strip illegal characters
Base64 is reversible, but for debugging/introspection, it's really nice when the file names look as much like the names as possible. Just keeps everything more debuggable. Approach B isn't reversible, so the "actual" name has to be stored redundantly anyway, so there's no real value in not just using a uuid or something.
This if specifically for Linux. While this isn't python specific, that's what I'm implementing it in.