Skip to content

Commit

Permalink
multipart boundary should be handled as mixed case
Browse files Browse the repository at this point in the history
Since w3c/FileAPI#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
  • Loading branch information
Olli Pettay authored and moz-wptsync-bot committed Jul 11, 2022
1 parent 9989c35 commit 35653f6
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions fetch/content-type/multipart.window.js
Original file line number Diff line number Diff line change
@@ -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();
})();

0 comments on commit 35653f6

Please sign in to comment.