`Base64Decoder` raises `DecodeError` on line-wrapped (MIME-style) base64
Maintainer thường phản hồi trong vòng 1 ngày
Đá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
- 25/100
Hướng nghiên cứu
Start by reading Base64Decoder.write() and reproduce the failure with the provided CRLF example, then try split writes and base64.encodebytes data in small chunks. A regression test should show that MIME-wrapped input decodes to the expected bytes regardless of line breaks or chunk boundaries; pull request #341 already submits a fix.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Base64Decoder.write() slices the input to a multiple of 4 bytes before decoding, but it counts line breaks and spaces as base64 characters. Standard base64 as used in MIME (RFC 2045) is wrapped with CRLF or LF, so any quartet that straddles a line break is miscounted and decoding fails. The result also depends on how the stream is chunked.
Reproduction
from io import BytesIO
from python_multipart.decoders import Base64Decoder
out = BytesIO()
d = Base64Decoder(out)
d.write(b"Zm9v\r\nYmFy") # DecodeError
d.finalize()
Expected: b"foobar", which is what base64.b64decode(b"Zm9v\r\nYmFy") returns.
Split writes fail the same way:
d.write(b"Zm9v\r")
d.write(b"\nYmFy") # DecodeError
base64.encodebytes(bytes(range(200))) (76-character lines) written in chunks of 10, 7 or 1 bytes also raises DecodeError.
Cause
write() computes decode_len = (len(data) // 4) * 4 on data that still contains \r, \n, space and tab. b64decode() then discards those bytes (it is not called with validate=True), leaving a slice that is not a multiple of 4, and raises "Incorrect padding".
Version: python-multipart 0.0.32, main at 51ff1a4, Python 3.13.
Fix
A fix with a regression test is submitted in #341.
- Ngôn ngữ chính
- Python
- Star
- 537
- Fork
- 104
- Merge trung bình
- 3 giờ
- Pull request đã merge (30 ngày)
- 4
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
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 Kludex/python-multipart
-
Add streaming field limits to `FormParser`Có thể đã có người làm @Kludex đã nhận 18 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 30/100
Kludex/python-multipart#332 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Clarify or handle non-Latin-1 str input in parse_options_headerCó thể đã có người làm @gyanu2507 đã nhận 60 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
Kludex/python-multipart#319 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
How to set FormParser MAX_BODY_SIZE, MAX_MEMORY_FILE_SIZE?Có thể đã có người làm @dokson đã nhận 138 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
Kludex/python-multipart#201 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Skip header area?Có thể đã có người làm @Kludex đã nhận 195 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 48/100
Kludex/python-multipart#59 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Failing to parse non-standard line breaksCó thể đã có người làm @dokson đã nhận 138 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 32/100
Kludex/python-multipart#31 · 4 bình luận · 4 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của Kludex/python-multipart
Issue tương tự
-
follow-up
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Download helper still uses huggingface_hub arguments removed in 1.0: USE_SYMLINKS is silently ignored and every download ends with a WinError 3 lineCó thể đã có người làm @li-lizhe đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
IPv6 node addresses produce an invalid request URLCó thể đã có người làm @RaphaelFakhri đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
typesense/typesense-python#154 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
elastic/elasticsearch-py#3592 ·
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 77/100
developmentseed/titiler-cmr#250 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày