From 3a4956b82ac7f9937ba6c772c643faeda1589ddd Mon Sep 17 00:00:00 2001 From: Olli Pettay Date: Mon, 11 Jul 2022 19:50:34 +0000 Subject: [PATCH] multipart boundary should be handled as mixed case Since https://github.com/w3c/FileAPI/issues/43 is still open, it is unclear how body.type should work. The current wpts expect some behavior which isn't in the specifications. So, since the situation is very messy in the specifications, the patch is doing a spot fix for boundary handling. It is ugly, but shouldn't change other behavior. Differential Revision: https://phabricator.services.mozilla.com/D150018 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1775501 gecko-commit: 22a157de1bfa502e10ec05c9b17611f2eba47b0e gecko-reviewers: kershaw --- fetch/content-type/multipart.window.js | 33 ++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 fetch/content-type/multipart.window.js diff --git a/fetch/content-type/multipart.window.js b/fetch/content-type/multipart.window.js new file mode 100644 index 00000000000000..03b037a0e621cf --- /dev/null +++ b/fetch/content-type/multipart.window.js @@ -0,0 +1,33 @@ +// META: title=Ensure capital letters can be used in the boundary value. +setup({ single_test: true }); +(async () => { + const form_string = + "--Boundary_with_capital_letters\r\n" + + "Content-Type: application/json\r\n" + + 'Content-Disposition: form-data; name="does_this_work"\r\n' + + "\r\n" + + 'YES\r\n' + + "--Boundary_with_capital_letters--\r\n"; + + const r = new Response(new Blob([form_string]), { + headers: [ + [ + "Content-Type", + "multipart/form-data; boundary=Boundary_with_capital_letters", + ], + ], + }); + + var s = ""; + try { + const fd = await r.formData(); + for (const [key, value] of fd.entries()) { + s += (`${key} = ${value}`); + } + } catch (ex) { + s = ex; + } + + assert_equals(s, "does_this_work = YES"); + done(); +})();