Title: [230963] trunk
Revision
230963
Author
[email protected]
Date
2018-04-24 11:15:48 -0700 (Tue, 24 Apr 2018)

Log Message

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

Patch by Tadeu Zagallo <[email protected]> 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.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (230962 => 230963)


--- trunk/LayoutTests/ChangeLog	2018-04-24 17:50:50 UTC (rev 230962)
+++ trunk/LayoutTests/ChangeLog	2018-04-24 18:15:48 UTC (rev 230963)
@@ -1,3 +1,16 @@
+2018-04-24  Tadeu Zagallo  <[email protected]>
+
+        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  Daniel Bates  <[email protected]>
 
         Implement Same-Site cookies

Added: trunk/LayoutTests/http/tests/local/formdata/send-form-data-with-empty-file-expected.txt (0 => 230963)


--- trunk/LayoutTests/http/tests/local/formdata/send-form-data-with-empty-file-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/local/formdata/send-form-data-with-empty-file-expected.txt	2018-04-24 18:15:48 UTC (rev 230963)
@@ -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
+

Added: trunk/LayoutTests/http/tests/local/formdata/send-form-data-with-empty-file.html (0 => 230963)


--- trunk/LayoutTests/http/tests/local/formdata/send-form-data-with-empty-file.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/local/formdata/send-form-data-with-empty-file.html	2018-04-24 18:15:48 UTC (rev 230963)
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+<form action="" method="post" enctype="multipart/form-data">
+  <input name="file" type="file">
+</form>
+<script src=""
+<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=""
+</body>
+</html>
+

Modified: trunk/Source/WebCore/ChangeLog (230962 => 230963)


--- trunk/Source/WebCore/ChangeLog	2018-04-24 17:50:50 UTC (rev 230962)
+++ trunk/Source/WebCore/ChangeLog	2018-04-24 18:15:48 UTC (rev 230963)
@@ -1,3 +1,19 @@
+2018-04-24  Tadeu Zagallo  <[email protected]>
+
+        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  Zalan Bujtas  <[email protected]>
 
         Fix project file after r230931.

Modified: trunk/Source/WebCore/platform/network/FormData.cpp (230962 => 230963)


--- trunk/Source/WebCore/platform/network/FormData.cpp	2018-04-24 17:50:50 UTC (rev 230962)
+++ trunk/Source/WebCore/platform/network/FormData.cpp	2018-04-24 18:15:48 UTC (rev 230963)
@@ -223,7 +223,7 @@
 
     if (!file.path().isEmpty())
         appendFile(file.path(), shouldGenerateFile);
-    else
+    else if (file.size())
         appendBlob(file.url());
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to