WebKit Bugzilla
Attachment 356961 Details for
Bug 192555
: [iOS] Unable to upload data that conforms to "public.item" but not "public.content"
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-192555-20181210084334.patch (text/plain), 7.97 KB, created by
Wenson Hsieh
on 2018-12-10 08:43:34 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Wenson Hsieh
Created:
2018-12-10 08:43:34 PST
Size:
7.97 KB
patch
obsolete
>Subversion Revision: 239026 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 2b560689ef5cdc45e7ebd16e3dbcf43de79e15ee..8ab1e5d9109f2545c1bf8fc888702c84ec7aa5b7 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,38 @@ >+2018-12-10 Wenson Hsieh <wenson_hsieh@apple.com> >+ >+ [iOS] Unable to upload data that conforms to "public.item" but not "public.content" >+ https://bugs.webkit.org/show_bug.cgi?id=192555 >+ <rdar://problem/35204990> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add support for uploading content that conforms to "public.item" via drag and drop. Currently, iOS WebKit only >+ supports data that conforms to "public.content", but there exist several types of files that conform to >+ "public.item" but not "public.content". See below for more detail. >+ >+ Test: DragAndDropTests.ExternalSourcePKCS12ToSingleFileInput >+ >+ * platform/ios/PasteboardIOS.mm: >+ (WebCore::Pasteboard::supportedFileUploadPasteboardTypes): >+ >+ Update this to include "public.item", and remove "public.folder", which is now redundant because "public.folder" >+ conforms to "public.item". >+ >+ * platform/ios/WebItemProviderPasteboard.mm: >+ (-[NSItemProvider web_containsFileURLAndFileUploadContent]): >+ >+ Pull out the "contains content that is supported for file uploads" part of this helper method into a separate >+ method, and use it within `-web_containsFileURLAndFileUploadContent`. Note that this prevents "public.url"- >+ conformant data from being uploaded as files (i.e., we never want to upload a URL string *itself* as a file). >+ Drawing this distinction ensures that we don't confuse item providers that contain just a URL as files when >+ dropping into a file upload area or file input (see API test: ExternalSourceZIPArchiveAndURLToSingleFileInput >+ for an example of this corner case). >+ >+ (-[NSItemProvider web_containsFileUploadContent]): >+ (-[WebItemProviderPasteboard numberOfFiles]): >+ >+ Refactor this to use `-web_containsFileUploadContent`. >+ > 2018-12-09 Youenn Fablet <youenn@apple.com> > > Move capture manager from RealtimeMediaSourceCenter to capture factory >diff --git a/Source/WebCore/platform/ios/PasteboardIOS.mm b/Source/WebCore/platform/ios/PasteboardIOS.mm >index 90fb3f6015e89ca6e5503ec5de0321be332295ea..05f0de49c45ddf11e5dfff2c2d9cb44abf2ca510 100644 >--- a/Source/WebCore/platform/ios/PasteboardIOS.mm >+++ b/Source/WebCore/platform/ios/PasteboardIOS.mm >@@ -345,7 +345,7 @@ NSArray *Pasteboard::supportedWebContentPasteboardTypes() > > NSArray *Pasteboard::supportedFileUploadPasteboardTypes() > { >- return @[ (NSString *)kUTTypeContent, (NSString *)kUTTypeZipArchive, (NSString *)kUTTypeFolder ]; >+ return @[ (__bridge NSString *)kUTTypeItem, (__bridge NSString *)kUTTypeContent, (__bridge NSString *)kUTTypeZipArchive ]; > } > > bool Pasteboard::hasData() >diff --git a/Source/WebCore/platform/ios/WebItemProviderPasteboard.mm b/Source/WebCore/platform/ios/WebItemProviderPasteboard.mm >index c7b75a52d1438c89e5c2ff900893e3588b6eb55d..c3275359eff8548a42128cff1e0cbf89f0f61f58 100644 >--- a/Source/WebCore/platform/ios/WebItemProviderPasteboard.mm >+++ b/Source/WebCore/platform/ios/WebItemProviderPasteboard.mm >@@ -66,19 +66,20 @@ @implementation NSItemProvider (WebCoreExtras) > > - (BOOL)web_containsFileURLAndFileUploadContent > { >- BOOL containsFileURL = NO; >- BOOL containsContentForFileUpload = NO; > for (NSString *identifier in self.registeredTypeIdentifiers) { >- if (UTTypeConformsTo((__bridge CFStringRef)identifier, kUTTypeFileURL)) { >- containsFileURL = YES; >- continue; >- } >+ if (UTTypeConformsTo((__bridge CFStringRef)identifier, kUTTypeFileURL)) >+ return self.web_containsFileUploadContent; >+ } >+ return NO; >+} > >+- (BOOL)web_containsFileUploadContent >+{ >+ for (NSString *identifier in self.registeredTypeIdentifiers) { > if (UTTypeConformsTo((__bridge CFStringRef)identifier, kUTTypeURL)) > continue; > >- containsContentForFileUpload |= typeConformsToTypes(identifier, Pasteboard::supportedFileUploadPasteboardTypes()); >- if (containsContentForFileUpload && containsFileURL) >+ if (typeConformsToTypes(identifier, Pasteboard::supportedFileUploadPasteboardTypes())) > return YES; > } > return NO; >@@ -670,20 +671,21 @@ - (NSArray<NSURL *> *)allDroppedFileURLs > > - (NSInteger)numberOfFiles > { >- NSArray *supportedFileTypes = Pasteboard::supportedFileUploadPasteboardTypes(); > NSInteger numberOfFiles = 0; > for (NSItemProvider *itemProvider in _itemProviders.get()) { > #if !PLATFORM(IOSMAC) >+ // First, check if the source has explicitly indicated that this item should or should not be treated as an attachment. > if (itemProvider.preferredPresentationStyle == UIPreferredPresentationStyleInline) > continue; >-#endif > >- for (NSString *identifier in itemProvider.registeredTypeIdentifiers) { >- if (!typeConformsToTypes(identifier, supportedFileTypes)) >- continue; >+ if (itemProvider.preferredPresentationStyle == UIPreferredPresentationStyleAttachment) { > ++numberOfFiles; >- break; >+ continue; > } >+#endif >+ // Otherwise, fall back to examining the item's registered type identifiers. >+ if (itemProvider.web_containsFileUploadContent) >+ ++numberOfFiles; > } > return numberOfFiles; > } >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index e871b83e9dc3ccd87424287b55a04cc3cf8ed7ca..e35bc045bac20ffe83fe0d4512d6bff541af0cfa 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,19 @@ >+2018-12-10 Wenson Hsieh <wenson_hsieh@apple.com> >+ >+ [iOS] Unable to upload data that conforms to "public.item" but not "public.content" >+ https://bugs.webkit.org/show_bug.cgi?id=192555 >+ <rdar://problem/35204990> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add a test to verify that `.p12` files may be uploaded as files via drag and drop. "com.rsa.pkcs-12" is an >+ example of a data type that conforms to "public.item", but not "public.content"; before this patch, we would >+ only support uploading "public.content", so files such as these would not be accepted when dropping into file >+ inputs, or be exposed as files on DataTransfer. >+ >+ * TestWebKitAPI/Tests/ios/DragAndDropTestsIOS.mm: >+ (TestWebKitAPI::TEST): >+ > 2018-12-10 Tim Horton <timothy_horton@apple.com> > > WKWebView should support custom tintColor >diff --git a/Tools/TestWebKitAPI/Tests/ios/DragAndDropTestsIOS.mm b/Tools/TestWebKitAPI/Tests/ios/DragAndDropTestsIOS.mm >index 2c81e57b8b794dd920fe1e37564ac39ec09c1514..975d704c1e73034218d90dbd6d2b1fc2dfdbba8c 100644 >--- a/Tools/TestWebKitAPI/Tests/ios/DragAndDropTestsIOS.mm >+++ b/Tools/TestWebKitAPI/Tests/ios/DragAndDropTestsIOS.mm >@@ -701,6 +701,21 @@ TEST(DragAndDropTests, ExternalSourceMoveOperationNotAllowed) > EXPECT_WK_STREQ("", [webView stringByEvaluatingJavaScript:@"output.value"]); > } > >+TEST(DragAndDropTests, ExternalSourcePKCS12ToSingleFileInput) >+{ >+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); >+ [webView synchronouslyLoadTestPageNamed:@"file-uploading"]; >+ >+ auto item = adoptNS([[NSItemProvider alloc] init]); >+ [item registerDataRepresentationForTypeIdentifier:(__bridge NSString *)kUTTypePKCS12 withData:[@"Not a real p12 file." dataUsingEncoding:NSUTF8StringEncoding]]; >+ >+ auto simulator = adoptNS([[DragAndDropSimulator alloc] initWithWebView:webView.get()]); >+ [simulator setExternalItemProviders:@[ item.get() ]]; >+ [simulator runFrom:CGPointMake(200, 100) to:CGPointMake(100, 100)]; >+ >+ EXPECT_WK_STREQ("application/x-pkcs12", [webView stringByEvaluatingJavaScript:@"output.value"]); >+} >+ > TEST(DragAndDropTests, ExternalSourceZIPArchiveAndURLToSingleFileInput) > { > auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 192555
: 356961