Title: [236343] trunk/Source/WebKit
Revision
236343
Author
[email protected]
Date
2018-09-21 12:19:55 -0700 (Fri, 21 Sep 2018)

Log Message

Regression(Mojave): Resuming a WK2 download crashes
https://bugs.webkit.org/show_bug.cgi?id=189838
<rdar://problem/44618538>

Reviewed by Alex Christensen.

Update our workaround to tweak the download resume data to include the actual download path so that
it works on macOS Mojave and up. Unfortunately, the resume data internal representation has changed,
causing our previous workaround to fail.

* NetworkProcess/Downloads/cocoa/DownloadCocoa.mm:
(WebKit::Download::resume):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (236342 => 236343)


--- trunk/Source/WebKit/ChangeLog	2018-09-21 18:56:00 UTC (rev 236342)
+++ trunk/Source/WebKit/ChangeLog	2018-09-21 19:19:55 UTC (rev 236343)
@@ -1,3 +1,18 @@
+2018-09-21  Chris Dumez  <[email protected]>
+
+        Regression(Mojave): Resuming a WK2 download crashes
+        https://bugs.webkit.org/show_bug.cgi?id=189838
+        <rdar://problem/44618538>
+
+        Reviewed by Alex Christensen.
+
+        Update our workaround to tweak the download resume data to include the actual download path so that
+        it works on macOS Mojave and up. Unfortunately, the resume data internal representation has changed,
+        causing our previous workaround to fail.
+
+        * NetworkProcess/Downloads/cocoa/DownloadCocoa.mm:
+        (WebKit::Download::resume):
+
 2018-09-21  Youenn Fablet  <[email protected]>
 
         Whitelist two additional plugins

Modified: trunk/Source/WebKit/NetworkProcess/Downloads/cocoa/DownloadCocoa.mm (236342 => 236343)


--- trunk/Source/WebKit/NetworkProcess/Downloads/cocoa/DownloadCocoa.mm	2018-09-21 18:56:00 UTC (rev 236342)
+++ trunk/Source/WebKit/NetworkProcess/Downloads/cocoa/DownloadCocoa.mm	2018-09-21 19:19:55 UTC (rev 236343)
@@ -48,9 +48,26 @@
     auto nsData = adoptNS([[NSData alloc] initWithBytes:resumeData.data() length:resumeData.size()]);
 
     // FIXME: This is a temporary workaround for <rdar://problem/34745171>.
-    NSMutableDictionary *dictionary = [NSPropertyListSerialization propertyListWithData:nsData.get() options:NSPropertyListImmutable format:0 error:nullptr];
+#if (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 120000) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400)
+    static NSSet<Class> *plistClasses = nil;
+    static dispatch_once_t onceToken;
+
+    dispatch_once(&onceToken, ^{
+        plistClasses = [[NSSet setWithObjects:[NSDictionary class], [NSArray class], [NSString class], [NSNumber class], [NSData class], [NSURL class], [NSURLRequest class], nil] retain];
+    });
+    auto unarchiver = adoptNS([[NSKeyedUnarchiver alloc] initForReadingFromData:nsData.get() error:nil]);
+    [unarchiver setDecodingFailurePolicy:NSDecodingFailurePolicyRaiseException];
+    auto dictionary = retainPtr([unarchiver decodeObjectOfClasses:plistClasses forKey:@"NSKeyedArchiveRootObjectKey"]);
+    [unarchiver finishDecoding];
     [dictionary setObject:static_cast<NSString*>(path) forKey:@"NSURLSessionResumeInfoLocalPath"];
+    auto encoder = adoptNS([[NSKeyedArchiver alloc] initRequiringSecureCoding:YES]);
+    [encoder encodeObject:dictionary.get() forKey:@"NSKeyedArchiveRootObjectKey"];
+    NSData *updatedData = [encoder encodedData];
+#else
+    NSMutableDictionary *dictionary = [NSPropertyListSerialization propertyListWithData:nsData.get() options:NSPropertyListMutableContainersAndLeaves format:0 error:nullptr];
+    [dictionary setObject:static_cast<NSString*>(path) forKey:@"NSURLSessionResumeInfoLocalPath"];
     NSData *updatedData = [NSPropertyListSerialization dataWithPropertyList:dictionary format:NSPropertyListXMLFormat_v1_0 options:0 error:nullptr];
+#endif
 
     m_downloadTask = cocoaSession.downloadTaskWithResumeData(updatedData);
     cocoaSession.addDownloadID(m_downloadTask.get().taskIdentifier, m_downloadID);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to