gradio
4a4c7f3b - preserve file extension when filename stem is stripped entirely in gr.File (#12979)

Commit
37 days ago
preserve file extension when filename stem is stripped entirely in gr.File (#12979) * fix: preserve file extension when filename stem is stripped entirely When uploading a file whose name consists entirely of characters that `strip_invalid_filename_characters` removes (e.g. `#.txt`), the stem becomes empty and the result is just `.txt`. `Path(".txt").suffix` returns an empty string (Python treats it as a dotfile stem), so the subsequent `is_valid_file` check fails with "Invalid file type" even though the actual extension is valid. Use fallback name `"file"` when the sanitized stem is empty but an extension exists, producing `file.txt` instead of `.txt`. Fixes #12075 Signed-off-by: Giulio Leone <6887247+giulio-leone@users.noreply.github.com> * add changeset * add changeset * chore: re-trigger CI (flaky network test) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Signed-off-by: Giulio Leone <6887247+giulio-leone@users.noreply.github.com> Co-authored-by: Giulio Leone <6887247+giulio-leone@users.noreply.github.com> Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Freddy Boulton <41651716+freddyaboulton@users.noreply.github.com>
Author
Parents
Loading