Regression(r242369) Trying to change profile picture on linked in shows file picker...
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Mar 2019 05:48:08 +0000 (05:48 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Mar 2019 05:48:08 +0000 (05:48 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196205
<rdar://problem/49083324>

Reviewed by Geoffrey Garen.

Update our FileUploadPanel code on iOS to properly deal with the MIME types containing
wild cards (e.g. "image/*") that are defined in the HTML specification:
- https://html.spec.whatwg.org/multipage/input.html#attr-input-accept

Previously, we would fail to convert those to UTIs.

* UIProcess/ios/forms/WKFileUploadPanel.mm:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243485 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/ios/forms/WKFileUploadPanel.mm

index da381d4..186f3e4 100644 (file)
@@ -1,3 +1,19 @@
+2019-03-25  Chris Dumez  <cdumez@apple.com>
+
+        Regression(r242369) Trying to change profile picture on linked in shows file picker, not the image picker
+        https://bugs.webkit.org/show_bug.cgi?id=196205
+        <rdar://problem/49083324>
+
+        Reviewed by Geoffrey Garen.
+
+        Update our FileUploadPanel code on iOS to properly deal with the MIME types containing
+        wild cards (e.g. "image/*") that are defined in the HTML specification:
+        - https://html.spec.whatwg.org/multipage/input.html#attr-input-accept
+
+        Previously, we would fail to convert those to UTIs.
+
+        * UIProcess/ios/forms/WKFileUploadPanel.mm:
+
 2019-03-25  Tim Horton  <timothy_horton@apple.com>
 
         Remove some now-unnecessary dynamic class lookup
index 2ea09d3..1e94b8d 100644 (file)
@@ -318,9 +318,17 @@ static NSSet<NSString *> *UTIsForMIMETypes(NSArray *mimeTypes)
 {
     NSMutableSet *mediaTypes = [NSMutableSet set];
     for (NSString *mimeType in mimeTypes) {
-        auto uti = WebCore::UTIFromMIMEType(mimeType);
-        if (!uti.isEmpty())
-            [mediaTypes addObject:(__bridge NSString *)uti];
+        if ([mimeType caseInsensitiveCompare:@"image/*"] == NSOrderedSame)
+            [mediaTypes addObject:(__bridge NSString *)kUTTypeImage];
+        else if ([mimeType caseInsensitiveCompare:@"video/*"] == NSOrderedSame)
+            [mediaTypes addObject:(__bridge NSString *)kUTTypeMovie];
+        else if ([mimeType caseInsensitiveCompare:@"audio/*"] == NSOrderedSame)
+            [mediaTypes addObject:(__bridge NSString *)kUTTypeAudio];
+        else {
+            auto uti = WebCore::UTIFromMIMEType(mimeType);
+            if (!uti.isEmpty())
+                [mediaTypes addObject:(__bridge NSString *)uti];
+        }
     }
     return mediaTypes;
 }