Title: [281612] trunk
Revision
281612
Author
akeer...@apple.com
Date
2021-08-25 20:08:42 -0700 (Wed, 25 Aug 2021)

Log Message

[iOS] Unable to select files when the accept attribute is set to "*/*"
https://bugs.webkit.org/show_bug.cgi?id=229456
rdar://82346315

Reviewed by Chris Dumez.

Source/WebKit:

"*/*" is a valid MIME type string representing all media types. However,
the UniformTypeIdentifiers framework (as well as the now deprecated
CoreServices type identifiers API) does not map wildcard MIME types.

In order to restrict `UIDocumentPickerViewController` to the types of
files specified in the accept attribute, all MIME type strings are
converted into `UTType`s. However, when attempting to retrieve a UTType
for "*/*", the system dynamically generates a type, since the string is
unregistered. Then, since no files conform to the dynamic type, all
files in the document picker are greyed out, and the user is unable
to access the "Photo Library" and "Take Photo or Video" items.

To fix, return an empty set of type identifiers whenever "*/*" is
present in the list of MIME types, ensuring there are no restrictions
on the types of files that can be selected.

Note that the same issue does not occur on macOS, since all MIME types
are mapped to a set of file extensions, rather than UTTypes. Furthermore,
on macOS, the embedding app, not WebKit, is responsible for displaying
the file picker.

* UIProcess/ios/forms/WKFileUploadPanel.mm:

LayoutTests:

Updated tests to verify that setting the accept attribute to "*/*" does
not impose any restrictions on the types of files that can be selected,
and gives the user access to all menu options.

* fast/forms/ios/file-upload-panel-accept-expected.txt:
* fast/forms/ios/file-upload-panel-accept.html:
* fast/forms/ios/file-upload-panel-expected.txt:
* fast/forms/ios/file-upload-panel.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (281611 => 281612)


--- trunk/LayoutTests/ChangeLog	2021-08-26 03:07:24 UTC (rev 281611)
+++ trunk/LayoutTests/ChangeLog	2021-08-26 03:08:42 UTC (rev 281612)
@@ -1,3 +1,20 @@
+2021-08-25  Aditya Keerthi  <akeer...@apple.com>
+
+        [iOS] Unable to select files when the accept attribute is set to "*/*"
+        https://bugs.webkit.org/show_bug.cgi?id=229456
+        rdar://82346315
+
+        Reviewed by Chris Dumez.
+
+        Updated tests to verify that setting the accept attribute to "*/*" does
+        not impose any restrictions on the types of files that can be selected,
+        and gives the user access to all menu options.
+
+        * fast/forms/ios/file-upload-panel-accept-expected.txt:
+        * fast/forms/ios/file-upload-panel-accept.html:
+        * fast/forms/ios/file-upload-panel-expected.txt:
+        * fast/forms/ios/file-upload-panel.html:
+
 2021-08-25  Chris Dumez  <cdu...@apple.com>
 
         REGRESSION (r281516): [AppleSilicon WK2] fast/loader/reload-zero-byte-plugin.html is timing out

Modified: trunk/LayoutTests/fast/forms/ios/file-upload-panel-accept-expected.txt (281611 => 281612)


--- trunk/LayoutTests/fast/forms/ios/file-upload-panel-accept-expected.txt	2021-08-26 03:07:24 UTC (rev 281611)
+++ trunk/LayoutTests/fast/forms/ios/file-upload-panel-accept-expected.txt	2021-08-26 03:08:42 UTC (rev 281612)
@@ -6,6 +6,9 @@
 * accept =
 PASS areArraysEqual(items, []) is true
 
+* accept = */*
+PASS areArraysEqual(items, []) is true
+
 * accept = image/*
 PASS areArraysEqual(items, ["public.image"]) is true
 

Modified: trunk/LayoutTests/fast/forms/ios/file-upload-panel-accept.html (281611 => 281612)


--- trunk/LayoutTests/fast/forms/ios/file-upload-panel-accept.html	2021-08-26 03:07:24 UTC (rev 281611)
+++ trunk/LayoutTests/fast/forms/ios/file-upload-panel-accept.html	2021-08-26 03:08:42 UTC (rev 281612)
@@ -29,6 +29,7 @@
     description("Tests that the accept attribute for file inputs is mapped to the correct set of type identifiers on iOS.");
 
     await runTest("", '[]');
+    await runTest("*/*", '[]');
     await runTest("image/*", '["public.image"]');
     await runTest("video/*", '["public.movie"]');
     await runTest("image/*, video/*", '["public.image", "public.movie"]');

Modified: trunk/LayoutTests/fast/forms/ios/file-upload-panel-expected.txt (281611 => 281612)


--- trunk/LayoutTests/fast/forms/ios/file-upload-panel-expected.txt	2021-08-26 03:07:24 UTC (rev 281611)
+++ trunk/LayoutTests/fast/forms/ios/file-upload-panel-expected.txt	2021-08-26 03:08:42 UTC (rev 281612)
@@ -6,6 +6,9 @@
 * accept =
 PASS areArraysEqual(items, ["Photo Library", "Take Photo or Video", "Choose File"]) is true
 
+* accept = */*
+PASS areArraysEqual(items, ["Photo Library", "Take Photo or Video", "Choose File"]) is true
+
 * accept = image/*
 PASS areArraysEqual(items, ["Photo Library", "Take Photo", "Choose File"]) is true
 

Modified: trunk/LayoutTests/fast/forms/ios/file-upload-panel.html (281611 => 281612)


--- trunk/LayoutTests/fast/forms/ios/file-upload-panel.html	2021-08-26 03:07:24 UTC (rev 281611)
+++ trunk/LayoutTests/fast/forms/ios/file-upload-panel.html	2021-08-26 03:08:42 UTC (rev 281612)
@@ -62,6 +62,7 @@
     document.getElementById("console").style = "display: none";
 
     await runAcceptTest("", '["Photo Library", "Take Photo or Video", "Choose File"]');
+    await runAcceptTest("*/*", '["Photo Library", "Take Photo or Video", "Choose File"]');
     await runAcceptTest("image/*", '["Photo Library", "Take Photo", "Choose File"]');
     await runAcceptTest("video/*", '["Photo Library", "Take Video", "Choose File"]');
     await runAcceptTest("image/*, video/*", '["Photo Library", "Take Photo or Video", "Choose File"]');

Modified: trunk/Source/WebKit/ChangeLog (281611 => 281612)


--- trunk/Source/WebKit/ChangeLog	2021-08-26 03:07:24 UTC (rev 281611)
+++ trunk/Source/WebKit/ChangeLog	2021-08-26 03:08:42 UTC (rev 281612)
@@ -1,3 +1,34 @@
+2021-08-25  Aditya Keerthi  <akeer...@apple.com>
+
+        [iOS] Unable to select files when the accept attribute is set to "*/*"
+        https://bugs.webkit.org/show_bug.cgi?id=229456
+        rdar://82346315
+
+        Reviewed by Chris Dumez.
+
+        "*/*" is a valid MIME type string representing all media types. However,
+        the UniformTypeIdentifiers framework (as well as the now deprecated
+        CoreServices type identifiers API) does not map wildcard MIME types.
+
+        In order to restrict `UIDocumentPickerViewController` to the types of
+        files specified in the accept attribute, all MIME type strings are
+        converted into `UTType`s. However, when attempting to retrieve a UTType
+        for "*/*", the system dynamically generates a type, since the string is
+        unregistered. Then, since no files conform to the dynamic type, all
+        files in the document picker are greyed out, and the user is unable
+        to access the "Photo Library" and "Take Photo or Video" items.
+
+        To fix, return an empty set of type identifiers whenever "*/*" is
+        present in the list of MIME types, ensuring there are no restrictions
+        on the types of files that can be selected.
+
+        Note that the same issue does not occur on macOS, since all MIME types
+        are mapped to a set of file extensions, rather than UTTypes. Furthermore,
+        on macOS, the embedding app, not WebKit, is responsible for displaying
+        the file picker.
+
+        * UIProcess/ios/forms/WKFileUploadPanel.mm:
+
 2021-08-25  Wenson Hsieh  <wenson_hs...@apple.com>
 
         Remove some iOS-specific compile-time guards that are no longer needed

Modified: trunk/Source/WebKit/UIProcess/ios/forms/WKFileUploadPanel.mm (281611 => 281612)


--- trunk/Source/WebKit/UIProcess/ios/forms/WKFileUploadPanel.mm	2021-08-26 03:07:24 UTC (rev 281611)
+++ trunk/Source/WebKit/UIProcess/ios/forms/WKFileUploadPanel.mm	2021-08-26 03:08:42 UTC (rev 281612)
@@ -355,6 +355,9 @@
 {
     NSMutableSet *mediaTypes = [NSMutableSet set];
     for (NSString *mimeType in mimeTypes) {
+        if ([mimeType isEqualToString:@"*/*"])
+            return [NSSet set];
+
         if ([mimeType caseInsensitiveCompare:@"image/*"] == NSOrderedSame)
             [mediaTypes addObject:UTTypeImage.identifier];
         else if ([mimeType caseInsensitiveCompare:@"video/*"] == NSOrderedSame)
@@ -368,7 +371,6 @@
             if (uti)
                 [mediaTypes addObject:uti.identifier];
         }
-
     }
     return mediaTypes;
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to