[Python] What is the best way to sanitize uploaded filenames in Django?

Discussão em 'Python' iniciado por Stack, Outubro 5, 2024.

  1. Stack

    Stack Membro Participativo

    I tried using slugify however it made too many changes to the original filename, such as removing spaces joining the file extension to the rest of the name. I'd like to simply ensure that names are safe: 1. Not too long and 2. Prevent any attacks that can be carried out using the file's name(such as path traversal).

    My app allows users to upload files(files are uploaded to DigitalOcean Spaces via my app) and filenames are stored using models.py/

    Continue reading...

Compartilhe esta Página