Changeset 285808 in webkit


Ignore:
Timestamp:
Nov 15, 2021 9:32:18 AM (8 months ago)
Author:
commit-queue@webkit.org
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 <andreu@andreubotella.com> 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):

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r285803 r285808  
     12021-11-15  Andreu Botella  <andreu@andreubotella.com>
     2
     3        Empty <input type=file> controls don't show up in the urlencoded and text/plain enctypes
     4        https://bugs.webkit.org/show_bug.cgi?id=221549
     5
     6        Reviewed by Chris Dumez.
     7
     8        * web-platform-tests/html/semantics/forms/form-submission-0/form-data-set-empty-file.window-expected.txt:
     9
    1102021-11-15  Cathie Chen  <cathiechen@igalia.com>
    211
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/form-submission-0/form-data-set-empty-file.window-expected.txt

    r279427 r285808  
    11
    22FAIL Empty <input type=file> is still added to the form's entry list assert_equals: type expected "application/octet-stream" but got ""
    3 FAIL Empty <input type=file> shows up in the urlencoded serialization assert_equals: expected "hi=" but got ""
     3PASS Empty <input type=file> shows up in the urlencoded serialization
    44PASS Empty <input type=file> shows up in the multipart/form-data serialization
    5 FAIL Empty <input type=file> shows up in the text/plain serialization assert_equals: expected "hi=\n" but got ""
     5FAIL Empty <input type=file> shows up in the text/plain serialization assert_equals: expected "hi=\n" but got "hi="
    66
  • trunk/Source/WebCore/ChangeLog

    r285807 r285808  
     12021-11-15  Andreu Botella  <andreu@andreubotella.com>
     2
     3        Empty <input type=file> controls don't show up in the urlencoded and text/plain enctypes
     4        https://bugs.webkit.org/show_bug.cgi?id=221549
     5
     6        Reviewed by Chris Dumez.
     7
     8        In the HTML spec, and in Firefox and Chrome's implementations, an empty <input type="file">
     9        control is represented in form submission as if it were an empty file with an empty
     10        filename. WebKit, however, does not include a form entry corresponding to the file input at
     11        all in the application/x-www-form-urlencoded and text/plain enctypes. This change fixes it.
     12
     13        Tests: imported/w3c/web-platform-tests/html/semantics/forms/form-submission-0/form-data-set-empty-file.window.html
     14
     15        * html/FileInputType.cpp:
     16        (WebCore::FileInputType::appendFormData const):
     17
    1182021-11-15  Antti Koivisto  <antti@apple.com>
    219
  • trunk/Source/WebCore/html/FileInputType.cpp

    r284009 r285808  
    171171        // 4.10.16.4 and 4.10.16.6 sections in HTML5.
    172172
    173         // Unlike the multipart case, we have no special handling for the empty
    174         // fileList because Netscape doesn't support for non-multipart
    175         // submission of file inputs, and Firefox doesn't add "name=" query
    176         // parameter.
     173        if (fileList->isEmpty())
     174            formData.append(name, "");
     175
    177176        for (auto& file : fileList->files())
    178177            formData.append(name, file->name());
Note: See TracChangeset for help on using the changeset viewer.