Skip to content

Commit

Permalink
Merge r230963 - REGRESSION(r221839): Fix requests with FormData conta…
Browse files Browse the repository at this point in the history
…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
tadeuzagallo authored and carlosgcampos committed May 7, 2018
1 parent be1c24c commit c8cab33
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 1 deletion.
13 changes: 13 additions & 0 deletions LayoutTests/ChangeLog
@@ -1,3 +1,16 @@
2018-04-24 Tadeu Zagallo <tzagallo@apple.com>

REGRESSION(r221839): Fix requests with FormData containing empty files
https://bugs.webkit.org/show_bug.cgi?id=184490
<rdar://problem/39385169>

Reviewed by Geoffrey Garen.

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.

2018-04-23 Antti Koivisto <antti@apple.com>

REGRESSION (r220112): reCAPTCHA images render off screen on Twitch.tv app Log In or Sign Up
Expand Down
@@ -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

@@ -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>

16 changes: 16 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,19 @@
2018-04-24 Tadeu Zagallo <tzagallo@apple.com>

REGRESSION(r221839): Fix requests with FormData containing empty files
https://bugs.webkit.org/show_bug.cgi?id=184490
<rdar://problem/39385169>

Reviewed by Geoffrey Garen.

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):

2018-04-24 Zan Dobersek <zdobersek@igalia.com>

[CoordGraphics] Avoid painting backing stores for zero-opacity layers
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/platform/network/FormData.cpp
Expand Up @@ -223,7 +223,7 @@ void FormData::appendMultiPartFileValue(const File& file, Vector<char>& header,

if (!file.path().isEmpty())
appendFile(file.path(), shouldGenerateFile);
else
else if (file.size())
appendBlob(file.url());
}

Expand Down

0 comments on commit c8cab33

Please sign in to comment.