Skip to content

fix(form-data): preserve leading BOM in multipart text parts#317

Merged
andreiltd merged 1 commit into
bytecodealliance:mainfrom
watilde:fix/form-data-preserve-bom
Jul 20, 2026
Merged

fix(form-data): preserve leading BOM in multipart text parts#317
andreiltd merged 1 commit into
bytecodealliance:mainfrom
watilde:fix/form-data-preserve-bom

Conversation

@watilde

@watilde watilde commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Per the Fetch spec, a multipart/form-data part without a filename is decoded with "UTF-8 decode without BOM", which preserves a leading U+FEFF. The parser used encoding_new_decoder_with_bom_removal, which strips it, so "\uFEFFhello" was returned as "hello".

Use encoding_new_decoder_without_bom_handling, matching the spec text already quoted in the surrounding comment. Add an integration test.

Per the Fetch spec, a multipart/form-data part without a filename is
decoded with "UTF-8 decode without BOM", which preserves a leading
U+FEFF. The parser used encoding_new_decoder_with_bom_removal, which
strips it, so "\uFEFFhello" was returned as "hello".

Use encoding_new_decoder_without_bom_handling, matching the spec text
already quoted in the surrounding comment. Add an integration test.

Signed-off-by: Daijiro Wachi <daijiro.wachi@gmail.com>

@andreiltd andreiltd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@andreiltd
andreiltd merged commit 17c0e12 into bytecodealliance:main Jul 20, 2026
7 checks passed
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.

2 participants