I want to convert/escape an untrusted string to a filename. The string can contain anything from *
, +
and /
to ../../etc/shadow
, which must not appear in a filename. I also want the filename to be as human-readable (i.e. close to the original string) as possible, so please avoid escaping alphanumeric characters like Abc123
since they are already valid characters. I'm on Ubuntu 20.04 in case it matters.
I am essentially looking for something like urllib.parse.quote
but for file paths. Any ideas?