Skip to content

Preserve bytes in multipart value fields. - #3012

Closed
pederbe wants to merge 1 commit into
rwf2:masterfrom
pederbe:learn/2934-multipart-binary
Closed

pederbe wants to merge 1 commit into
rwf2:masterfrom
pederbe:learn/2934-multipart-binary

Conversation

@pederbe

@pederbe pederbe commented Sep 25, 2026

Copy link
Copy Markdown

Multipart parts without a Content-Type currently pass through text decoding before reaching TempFile or byte-slice form guards. This replaces invalid UTF-8 and can strip or transcode byte-order marks, changing uploaded files even when a filename is supplied.

Retain the original part bytes and add defaulted raw-value callbacks to FromForm and FromFormField. Derived forms and built-in wrappers forward those bytes to binary guards, while existing text guards keep their decoding and value/data dispatch behavior. Headerless parts retain their existing buffered storage and data-form limit; explicit Content-Type parts keep streaming through the data-field path.

Custom form wrappers that forward value fields must also forward push_value_with_bytes to preserve binary contents in their inner guards. Transformed text retains both the original bytes and the decoded text. Regression coverage includes every byte value, both filename variants, byte-order marks, nested forms, legacy callbacks, limits, and cleanup.

With the dependency versions resolved locally, the full workspace build encounters a database dependency conflict that also reproduces on the unchanged base. Core tests and the examples suite pass.

Fixes #2934.

Retain multipart value bytes before text decoding and pass them through
new defaulted form callbacks. Forward the bytes through derived forms and
built-in wrappers so TempFile and byte-slice guards preserve uploads.
Keep existing text decoding, field classification, and limits.

Fixes rwf2#2934.
@pederbe
pederbe marked this pull request as ready for review September 25, 2026 15:44
@SergioBenitez

Copy link
Copy Markdown
Member

This is way over-scoped. The fix for the issue is way simpler. This is also clearly AI without little regard for human oversight.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Malformed data while Content Type is not specified in multipart forms

2 participants