Bug 221549 - Empty <input type=file> controls don't show up in the urlencoded and text/plain enctypes
Summary: Empty <input type=file> controls don't show up in the urlencoded and text/pla...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Forms (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-02-08 06:44 PST by Andreu Botella
Modified: 2022-02-04 12:46 PST (History)
13 users (show)

See Also:


Attachments
Patch (4.11 KB, patch)
2021-11-14 18:40 PST, Andreu Botella
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andreu Botella 2021-02-08 06:44:45 PST
The HTML spec's algorithm to construct the entry list (https://html.spec.whatwg.org/#constructing-the-form-data-set) requires that an <input type=file> control with no selected files is represented in the entry list as a File object. And WebKit follows this for the multipart/form-data enctype, but in the urlencoded and text/plain serializations that entry simply doesn't show up in the payload.

Tests: https://wpt.fyi/results/html/semantics/forms/form-submission-0/form-data-set-empty-file.window.html?label=pr_head&max-count=1&pr=27523
(this test file also tests for bug 185416)
Comment 1 Radar WebKit Bug Importer 2021-02-15 06:45:24 PST
<rdar://problem/74348545>
Comment 2 Andreu Botella 2021-11-14 18:40:51 PST
Created attachment 444206 [details]
Patch
Comment 3 EWS 2021-11-15 09:32:25 PST
Committed r285808 (244252@main): <https://commits.webkit.org/244252@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 444206 [details].
Comment 4 Darin Adler 2021-11-15 12:10:21 PST
Comment on attachment 444206 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=444206&action=review

> Source/WebCore/html/FileInputType.cpp:174
> +            formData.append(name, "");

I think this should probably be emptyString() instead of "", for better efficiency.
Comment 5 Andreu Botella 2021-11-16 18:11:30 PST
Comment on attachment 444206 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=444206&action=review

>> Source/WebCore/html/FileInputType.cpp:174
>> +            formData.append(name, "");
> 
> I think this should probably be emptyString() instead of "", for better efficiency.

Fixing this in https://bugs.webkit.org/show_bug.cgi?id=233229
Comment 6 Brent Fulgham 2022-02-04 12:46:39 PST
This change should be present in STP 139, iOS 15.4 Beta, and macOS 12.3 Beta.