download_file ignores the RFC 6266 filename* Content-Disposition parameter
Maintainer thường phản hồi trong vòng 4 ngày
@rahul05ranjan đang làm issue này rồi.
Từ ngày 28/10/2026.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 76/100
Hướng nghiên cứu
Bắt đầu với fsutil.download_file() và phần phân tích, làm sạch tên tệp hiện có được mô tả trong issue; sau đó tìm các bài kiểm thử và thêm một trường hợp sử dụng header Content-Disposition được cung cấp. Xác minh rằng filename* sau khi giải mã được ưu tiên và được làm sạch, còn các giá trị không hợp lệ hoặc bộ ký tự không xác định sẽ dùng phương án dự phòng như đã nêu.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
fsutil.download_file() only extracts the filename from the basic quoted parameter of Content-Disposition:
filename_pattern = r'filename="(.*)"'
However, many servers (S3, GitHub, browsers-side conventions) send the filename through the extended parameter when it contains non-ASCII characters, per RFC 6266 / RFC 5987:
Content-Disposition: attachment; filename="fallback.txt"; filename*=UTF-8''%E2%82%AC%20rates.txt
RFC 6266 says filename* takes precedence over filename. Today download_file() ignores filename* entirely, so such downloads are saved under a URL-derived name (or a random download-<uuid> name), silently dropping the server-provided filename.
Repro
class MockResponse:
headers = {"content-disposition": "attachment; filename=\"fallback.txt\"; filename*=UTF-8''%E2%82%AC%20rates.txt"}
...
path = fsutil.download_file("https://example.com/file.txt", dirpath=tmp)
# expected: "€ rates.txt" (from filename*)
# actual: "file.txt" (derived from the URL)
Expected behavior
- Parse
filename*=charset'language'percent-encoded-value(parameter name case-insensitive). - Percent-decode the value using the declared charset.
- Give it precedence over the basic
filenameparameter. - Keep the existing path-traversal sanitization (
\//normalization +os.path.basename) on the decoded value, since it comes from an untrusted header — the same hardening that #181 added for the basic parameter. - On an unknown charset or a malformed extended value, fall back to the basic
filenameparameter / URL / random name as before.
Happy to send a PR.
- Ngôn ngữ chính
- Python
- Star
- 268
- Fork
- 22
- Merge trung bình
- 4 ngày 11 giờ
- Pull request đã merge (30 ngày)
- 2
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của fabiocaccamo/python-fsutil
-
Atomic append fails to create a missing fileCó thể đã có người làm @harbinresearcher đã nhận 17 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
fabiocaccamo/python-fsutil#201 ·
Maintainer thường phản hồi trong vòng 4 ngày
-
get_unique_name appends to the previous candidate name when a collision triggers a retryCó thể đã có người làm @rahul05ranjan đã nhận 2 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
fabiocaccamo/python-fsutil#206 ·
Maintainer thường phản hồi trong vòng 4 ngày
-
Add `toml` files operation support.Có thể làm lại được @fabiocaccamo đã nhận 1337 ngày trước và không có pull request nào đang mở. Đang mởenhancement
fabiocaccamo/python-fsutil#42 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 4 ngày
Tất cả issue của fabiocaccamo/python-fsutil
Issue tương tự
-
getchaintips leaves out the active tip once a header is staged on it, where Core always lists itĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
btclib-org/btclib-node#2158 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
dbt-msft/dbt-sqlserver#897 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Gathin23/cleanyourtv#2770 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
vllm-project/vllm#64845 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
dekobon/big-code-analysis#1729 ·
Maintainer thường phản hồi trong vòng 1 ngày