Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge r230963 - REGRESSION(r221839): Fix requests with FormData conta…
…ining empty files https://bugs.webkit.org/show_bug.cgi?id=184490 <rdar://problem/39385169> Patch by Tadeu Zagallo <tzagallo@apple.com> on 2018-04-24 Reviewed by Geoffrey Garen. Source/WebCore: We should not append the blob to the FormData when it is a file but has no path. It broke the submission since the request was failing to read the file in FormDataStreamCFNet.h:156 Test: http/tests/local/formdata/send-form-data-with-empty-file.html * platform/network/FormData.cpp: (WebCore::FormData::appendMultiPartFileValue): LayoutTests: Verify that the final boundary is present in the request body when submitting FormData containing an empty file. * http/tests/local/formdata/send-form-data-with-empty-file-expected.txt: Added. * http/tests/local/formdata/send-form-data-with-empty-file.html: Added.
- Loading branch information
1 parent
be1c24c
commit c8cab33
Showing
5 changed files
with
69 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
LayoutTests/http/tests/local/formdata/send-form-data-with-empty-file-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Test that we correctly send forms with empty files | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS lines[0] + "--" is lines[lines.length - 1] | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
29 changes: 29 additions & 0 deletions
29
LayoutTests/http/tests/local/formdata/send-form-data-with-empty-file.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
</head> | ||
<body> | ||
<form action="http://127.0.0.1:8000/xmlhttprequest/resources/post-echo.cgi" method="post" enctype="multipart/form-data"> | ||
<input name="file" type="file"> | ||
</form> | ||
<script src="../../../../resources/js-test-pre.js"></script> | ||
<script> | ||
|
||
description("Test that we correctly send forms with empty files"); | ||
|
||
window.jsTestIsAsync = true; | ||
|
||
const form = document.forms[0]; | ||
const request = new XMLHttpRequest(); | ||
request.open("POST", form.action); | ||
request.onload = function() { | ||
lines = request.responseText.trim().split('\r\n'); | ||
shouldBe('lines[0] + "--"', 'lines[lines.length - 1]'); | ||
finishJSTest(); | ||
} | ||
request.send(new FormData(form)); | ||
</script> | ||
<script src="../../../../resources/js-test-post.js"></script> | ||
</body> | ||
</html> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters