-
-
Notifications
You must be signed in to change notification settings - Fork 687
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Bug Description
When sending a multipart/form-data with a filename*=utf-8'' (as the MultipartFormDataContent class in C# does for example, or in this example in the RFC: https://datatracker.ietf.org/doc/html/rfc6266#section-5) content disposition it throws a "Failed to parse body as FormData." TypeError.
Reproducible By
const response = new Response([
'--83d82e0d-9ced-44c0-ac79-4e66a827415b\r\n' +
'Content-Type: text/plain\r\n' +
'Content-Disposition: form-data; name="file"; filename*=utf-8\'\'file%20name.txt\r\n' +
'\r\n' +
'testabc\r\n' +
'--83d82e0d-9ced-44c0-ac79-4e66a827415b--\r\n' +
'\r\n',
].join(''), {
headers: {
'content-type': 'multipart/form-data; boundary="83d82e0d-9ced-44c0-ac79-4e66a827415b"'
}
});
await response.formData()
Expected Behavior
The existance of a filename*=utf-8 field shouldn't lead to parse failure, it should be used as the filename.
Logs & Screenshots
node:internal/deps/undici/undici:5619
throw new TypeError("Failed to parse body as FormData.");
^
TypeError: Failed to parse body as FormData.
at node:internal/deps/undici/undici:5619:27
at successSteps (node:internal/deps/undici/undici:5663:27)
at fullyReadBody (node:internal/deps/undici/undici:4561:9)
at async consumeBody (node:internal/deps/undici/undici:5672:7)
at async file:///index.js:15:1
Environment
This bug is NOT present in node v20.12.2, but IS present from node v20.13 and onward.
Additional context
Workaround: downgrade to node v20.12.2
zhouzhonghao
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working