fix: work around unarchivedObjectOfClass
requiring secureCoding
(#41319)
This commit is contained in:
parent
6a616ab70c
commit
0218af9af0
1 changed files with 16 additions and 6 deletions
|
@ -11,23 +11,33 @@ Several NSKeyedArchiver methods have been deprecated and replaced as of macOS 10
|
||||||
- archivedDataWithRootObject -> archivedDataWithRootObject:requiringSecureCoding:error:
|
- archivedDataWithRootObject -> archivedDataWithRootObject:requiringSecureCoding:error:
|
||||||
|
|
||||||
diff --git a/Squirrel/SQRLInstaller.m b/Squirrel/SQRLInstaller.m
|
diff --git a/Squirrel/SQRLInstaller.m b/Squirrel/SQRLInstaller.m
|
||||||
index f502df2f88424ea902a061adfeb30358daf212e4..8db6406ec7f0cb51140ea2ee39c04f91626f6e18 100644
|
index f502df2f88424ea902a061adfeb30358daf212e4..40f55812bf5795dc60bb8a4cd19c62cb37f40359 100644
|
||||||
--- a/Squirrel/SQRLInstaller.m
|
--- a/Squirrel/SQRLInstaller.m
|
||||||
+++ b/Squirrel/SQRLInstaller.m
|
+++ b/Squirrel/SQRLInstaller.m
|
||||||
@@ -182,14 +182,30 @@ - (SQRLInstallerOwnedBundle *)ownedBundle {
|
@@ -182,14 +182,40 @@ - (SQRLInstallerOwnedBundle *)ownedBundle {
|
||||||
id archiveData = CFBridgingRelease(CFPreferencesCopyValue((__bridge CFStringRef)SQRLInstallerOwnedBundleKey, (__bridge CFStringRef)self.applicationIdentifier, kCFPreferencesCurrentUser, kCFPreferencesCurrentHost));
|
id archiveData = CFBridgingRelease(CFPreferencesCopyValue((__bridge CFStringRef)SQRLInstallerOwnedBundleKey, (__bridge CFStringRef)self.applicationIdentifier, kCFPreferencesCurrentUser, kCFPreferencesCurrentHost));
|
||||||
if (![archiveData isKindOfClass:NSData.class]) return nil;
|
if (![archiveData isKindOfClass:NSData.class]) return nil;
|
||||||
|
|
||||||
- SQRLInstallerOwnedBundle *ownedBundle = [NSKeyedUnarchiver unarchiveObjectWithData:archiveData];
|
- SQRLInstallerOwnedBundle *ownedBundle = [NSKeyedUnarchiver unarchiveObjectWithData:archiveData];
|
||||||
- if (![ownedBundle isKindOfClass:SQRLInstallerOwnedBundle.class]) return nil;
|
- if (![ownedBundle isKindOfClass:SQRLInstallerOwnedBundle.class]) return nil;
|
||||||
|
+ // unarchivedObjectOfClass:fromData:error: sets secureCoding to true and we don't
|
||||||
|
+ // archive data with secureCoding enabled - use our own unarchiver to work around that.
|
||||||
+ NSError *error;
|
+ NSError *error;
|
||||||
+ SQRLInstallerOwnedBundle *ownedBundle = [NSKeyedUnarchiver unarchivedObjectOfClass:[SQRLInstallerOwnedBundle class]
|
+ NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingFromData:archiveData
|
||||||
+ fromData:archiveData
|
+ error:&error];
|
||||||
+ error:&error];
|
+ unarchiver.requiresSecureCoding = NO;
|
||||||
|
+ SQRLInstallerOwnedBundle *ownedBundle = [unarchiver decodeObjectForKey:NSKeyedArchiveRootObjectKey];
|
||||||
|
+ [unarchiver finishDecoding];
|
||||||
|
+
|
||||||
+ if (error) {
|
+ if (error) {
|
||||||
+ NSLog(@"Couldn't unarchive ownedBundle - %@", error.localizedDescription);
|
+ NSLog(@"Error while unarchiving ownedBundle - %@", error.localizedDescription);
|
||||||
+ return nil;
|
+ return nil;
|
||||||
+ }
|
+ }
|
||||||
|
+
|
||||||
|
+ if (!ownedBundle || ![ownedBundle isKindOfClass:SQRLInstallerOwnedBundle.class]) {
|
||||||
|
+ NSLog(@"Unknown error while unarchiving ownedBundle - did not conform to SQRLInstallerOwnedBundle");
|
||||||
|
+ return nil;
|
||||||
|
+ }
|
||||||
|
|
||||||
return ownedBundle;
|
return ownedBundle;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue