Skip to content

Commit

Permalink
Add CRLF to encoded multipart form data
Browse files Browse the repository at this point in the history
Some WPT tests were failing because they expected the body for a
multipart form data response to end with a CRLF. So I updated
encode_multipart_form_data to add the missing terminator.
  • Loading branch information
glowe committed Nov 29, 2019
1 parent afbcbf7 commit 3d322f9
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 12 deletions.
2 changes: 1 addition & 1 deletion components/script/dom/htmlformelement.rs
Expand Up @@ -1366,7 +1366,7 @@ pub fn encode_multipart_form_data(
}
}

let mut boundary_bytes = format!("\r\n--{}--", boundary).into_bytes();
let mut boundary_bytes = format!("\r\n--{}--\r\n", boundary).into_bytes();
result.append(&mut boundary_bytes);

result
Expand Down
Expand Up @@ -34,15 +34,6 @@
[Consume response's body: from FormData to formData]
expected: FAIL
[Consume response's body: from FormData to blob]
expected: FAIL

[Consume response's body: from FormData to text]
expected: FAIL
[Consume response's body: from FormData to arrayBuffer]
expected: FAIL

[Consume response's body: from stream to blob]
expected: FAIL

Expand Down
2 changes: 1 addition & 1 deletion tests/wpt/mozilla/meta/MANIFEST.json
Expand Up @@ -18442,7 +18442,7 @@
"testharness"
],
"mozilla/FileAPI/resource/file-submission.py": [
"24d5129eb8d38c9415622c78ed401ae344273ce1",
"79e72fb99a95c186e4916b40627ee762d694b8ea",
"support"
],
"mozilla/FileAPI/resource/upload.txt": [
Expand Down
Expand Up @@ -21,7 +21,7 @@ def main(request, response):
boundary = content_type[1].strip("boundary=")

body = "--" + boundary + "\r\nContent-Disposition: form-data; name=\"file-input\"; filename=\"upload.txt\""
body += "\r\n" + "content-type: text/plain\r\n\r\nHello\r\n--" + boundary + "--"
body += "\r\n" + "content-type: text/plain\r\n\r\nHello\r\n--" + boundary + "--\r\n"

if body != request.body:
return fail("request body doesn't match: " + body + "+++++++" + request.body)
Expand Down

0 comments on commit 3d322f9

Please sign in to comment.