Title: [285808] trunk
Revision
285808
Author
[email protected]
Date
2021-11-15 09:32:18 -0800 (Mon, 15 Nov 2021)

Log Message

Empty <input type=file> controls don't show up in the urlencoded and text/plain enctypes
https://bugs.webkit.org/show_bug.cgi?id=221549

Patch by Andreu Botella <[email protected]> on 2021-11-15
Reviewed by Chris Dumez.

LayoutTests/imported/w3c:

* web-platform-tests/html/semantics/forms/form-submission-0/form-data-set-empty-file.window-expected.txt:

Source/WebCore:

In the HTML spec, and in Firefox and Chrome's implementations, an empty <input type="file">
control is represented in form submission as if it were an empty file with an empty
filename. WebKit, however, does not include a form entry corresponding to the file input at
all in the application/x-www-form-urlencoded and text/plain enctypes. This change fixes it.

Tests: imported/w3c/web-platform-tests/html/semantics/forms/form-submission-0/form-data-set-empty-file.window.html

* html/FileInputType.cpp:
(WebCore::FileInputType::appendFormData const):

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (285807 => 285808)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-11-15 15:51:44 UTC (rev 285807)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-11-15 17:32:18 UTC (rev 285808)
@@ -1,3 +1,12 @@
+2021-11-15  Andreu Botella  <[email protected]>
+
+        Empty <input type=file> controls don't show up in the urlencoded and text/plain enctypes
+        https://bugs.webkit.org/show_bug.cgi?id=221549
+
+        Reviewed by Chris Dumez.
+
+        * web-platform-tests/html/semantics/forms/form-submission-0/form-data-set-empty-file.window-expected.txt:
+
 2021-11-15  Cathie Chen  <[email protected]>
 
         [CSS contain] Update css-contain tests from WPT

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/form-submission-0/form-data-set-empty-file.window-expected.txt (285807 => 285808)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/form-submission-0/form-data-set-empty-file.window-expected.txt	2021-11-15 15:51:44 UTC (rev 285807)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/form-submission-0/form-data-set-empty-file.window-expected.txt	2021-11-15 17:32:18 UTC (rev 285808)
@@ -1,6 +1,6 @@
 
 FAIL Empty <input type=file> is still added to the form's entry list assert_equals: type expected "application/octet-stream" but got ""
-FAIL Empty <input type=file> shows up in the urlencoded serialization assert_equals: expected "hi=" but got ""
+PASS Empty <input type=file> shows up in the urlencoded serialization
 PASS Empty <input type=file> shows up in the multipart/form-data serialization
-FAIL Empty <input type=file> shows up in the text/plain serialization assert_equals: expected "hi=\n" but got ""
+FAIL Empty <input type=file> shows up in the text/plain serialization assert_equals: expected "hi=\n" but got "hi="
 

Modified: trunk/Source/WebCore/ChangeLog (285807 => 285808)


--- trunk/Source/WebCore/ChangeLog	2021-11-15 15:51:44 UTC (rev 285807)
+++ trunk/Source/WebCore/ChangeLog	2021-11-15 17:32:18 UTC (rev 285808)
@@ -1,3 +1,20 @@
+2021-11-15  Andreu Botella  <[email protected]>
+
+        Empty <input type=file> controls don't show up in the urlencoded and text/plain enctypes
+        https://bugs.webkit.org/show_bug.cgi?id=221549
+
+        Reviewed by Chris Dumez.
+
+        In the HTML spec, and in Firefox and Chrome's implementations, an empty <input type="file">
+        control is represented in form submission as if it were an empty file with an empty
+        filename. WebKit, however, does not include a form entry corresponding to the file input at
+        all in the application/x-www-form-urlencoded and text/plain enctypes. This change fixes it.
+
+        Tests: imported/w3c/web-platform-tests/html/semantics/forms/form-submission-0/form-data-set-empty-file.window.html
+
+        * html/FileInputType.cpp:
+        (WebCore::FileInputType::appendFormData const):
+
 2021-11-15  Antti Koivisto  <[email protected]>
 
         [LFC][Integration] fast/text/international/bidi-innertext.html fails with BiDi enabled

Modified: trunk/Source/WebCore/html/FileInputType.cpp (285807 => 285808)


--- trunk/Source/WebCore/html/FileInputType.cpp	2021-11-15 15:51:44 UTC (rev 285807)
+++ trunk/Source/WebCore/html/FileInputType.cpp	2021-11-15 17:32:18 UTC (rev 285808)
@@ -170,10 +170,9 @@
         // Send only the basenames.
         // 4.10.16.4 and 4.10.16.6 sections in HTML5.
 
-        // Unlike the multipart case, we have no special handling for the empty
-        // fileList because Netscape doesn't support for non-multipart
-        // submission of file inputs, and Firefox doesn't add "name=" query
-        // parameter.
+        if (fileList->isEmpty())
+            formData.append(name, "");
+
         for (auto& file : fileList->files())
             formData.append(name, file->name());
         return true;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to