RESOLVED FIXED Bug 95698
HTML file input elements do not support file extensions in the "accept" attribute
https://bugs.webkit.org/show_bug.cgi?id=95698
Summary HTML file input elements do not support file extensions in the "accept" attri...
David Gatwood
Reported 2012-09-03 12:39:28 PDT
According to the current HTML spec: http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html#attr-input-accept The following is valid: <input type="file" accept=".myextension"> and should restrict the input to files with that extension. Safari 6 does not seem to support this form of that attribute. Please implement this functionality.
Attachments
Patch (8.63 KB, patch)
2017-08-01 17:25 PDT, Blaze Burg
darin: review+
Alexey Proskuryakov
Comment 1 2012-09-04 10:55:46 PDT
Could you please provide complete steps to reproduce? What specifically do you see that looks wrong - are you trying drag and drop, file chooser, or something else?
David Gatwood
Comment 2 2012-09-04 14:29:02 PDT
Step 1: Put the element in an HTML file. Step 2: Click on it. Step 3: Look at the file chooser. All files that do not match the above extension should be greyed out. They are not. Alternatively, include both an extension and one or more MIME types in the value, separated by commas. Click on the "Choose File" button. Notice that everything is greyed out except for files that match the MIME type(s), and you cannot choose anything that matches against the specified extension unless it also matches against one or more of the specified MIME types.
Jon Lee
Comment 3 2012-09-04 14:40:54 PDT
Currently it looks like WK2 only looks at MIME types, and ignores extensions. Chrome looks at the aggregate.
Radar WebKit Bug Importer
Comment 4 2012-09-04 14:41:29 PDT
Joseph Pecoraro
Comment 5 2012-09-04 23:32:09 PDT
Supporting extensions in <input type="file">'s accept attribute was a relatively recent addition to the HTML5 spec: <http://html5.org/tools/web-apps-tracker?from=7056&to=7057> It wasn't in the spec at the time that support was added to Safari. Neat, I didn't know about that.
Blaze Burg
Comment 6 2017-08-01 17:25:28 PDT
Build Bot
Comment 7 2017-08-01 17:28:16 PDT
Attachment 316918 [details] did not pass style-queue: ERROR: Source/WebKit/UIProcess/API/C/WKOpenPanelParametersRef.h:45: The parameter name "parameters" adds no information, so it should be removed. [readability/parameter_name] [5] Total errors found: 1 in 9 files If any of these errors are false positives, please file a bug against check-webkit-style.
Darin Adler
Comment 8 2017-08-01 18:22:08 PDT
Comment on attachment 316918 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=316918&action=review > Source/WebCore/ChangeLog:9 > + Serialize the accepted file extensions so they can be accessed in UIPRrocess. "UIPRrocess" -> "the UI process" > Source/WebKit/ChangeLog:12 > + Plumb accepted file extensions out to the C API. It is not > + added to the Cocoa API since the accepted MIME types are not > + available through that either. Better to add both together > + when they are actually needed. Not sure that is the right thing for our future direction. Instead I was hoping that we could make sure there was a way to bridge C API to Cocoa API so they can be mixed and then we would add this feature *only* to the Cocoa API. > Source/WebCore/platform/FileChooser.h:99 > + FileChooserClient* m_client = nullptr; WebKit uses the " { nullptr }" syntax instead of the "= nullptr" syntax. Arbitrary, I know.
Blaze Burg
Comment 9 2017-08-01 19:46:18 PDT
Comment on attachment 316918 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=316918&action=review >> Source/WebKit/ChangeLog:12 >> + when they are actually needed. > > Not sure that is the right thing for our future direction. > > Instead I was hoping that we could make sure there was a way to bridge C API to Cocoa API so they can be mixed and then we would add this feature *only* to the Cocoa API. I'm not sure how to accomplish that. Have we tried it anywhere else? I'm happy to change the Cocoa API in a separate patch to bring it up to parity. But it will require additional tests (API tests?) to make sure it's good for general consumption.
Tim Horton
Comment 10 2017-08-01 20:15:04 PDT
(In reply to Brian Burg from comment #9) > Comment on attachment 316918 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=316918&action=review > > >> Source/WebKit/ChangeLog:12 > >> + when they are actually needed. > > > > Not sure that is the right thing for our future direction. > > > > Instead I was hoping that we could make sure there was a way to bridge C API to Cocoa API so they can be mixed and then we would add this feature *only* to the Cocoa API. > > I'm not sure how to accomplish that. Have we tried it anywhere else? Most of the ObjC API objects are toll-free bridged with their C API counterparts. > I'm happy to change the Cocoa API in a separate patch to bring it up to > parity. But it will require additional tests (API tests?) to make sure it's > good for general consumption.
Blaze Burg
Comment 11 2017-08-02 10:39:01 PDT
Darin Adler
Comment 12 2017-08-02 13:52:20 PDT
(In reply to Brian Burg from comment #9) > I'm not sure how to accomplish that. Have we tried it anywhere else? Yes, I believe we have been taking that approach elsewhere. > I'm happy to change the Cocoa API in a separate patch to bring it up to > parity. But it will require additional tests (API tests?) to make sure it's > good for general consumption. I was not suggesting bringing it up to parity. I was suggesting putting new features *only* in Cocoa API and not adding to the C API.
Note You need to log in before you can comment on or make changes to this bug.