2 ms·
> what if you are trying to process "foreign"(as in, not created by you) filenames, trying to validate/conform with python? I mean its a great DoS vector, which
by oefrha 7y ago
> what if you are trying to process "foreign"(as in, not created by you) filenames, trying to validate/conform with python? I mean its a great DoS vector, which is difficult to protect against with python.
1. Have catch-all exception handling. Exception may not be your fault, exception-caused "crashing" whatever that means is entirely your fault.
2. Use os.fsdecode. https://docs.python.org/3/library/os.html#os.fsdecode https://docs.python.org/3/library/os.html#os.fsdecode
3. Don't process random untrusted filenames. Sanitize if it's some sort of HTTP upload, for instance.