diff --git a/patches/squirrel.mac/.patches b/patches/squirrel.mac/.patches index c36e985935b7..b6b24976e8c7 100644 --- a/patches/squirrel.mac/.patches +++ b/patches/squirrel.mac/.patches @@ -4,5 +4,5 @@ fix_use_kseccschecknestedcode_kseccsstrictvalidate_in_the_sec.patch feat_add_new_squirrel_mac_bundle_installation_method_behind_flag.patch refactor_use_posix_spawn_instead_of_nstask_so_we_can_disclaim_the.patch fix_abort_installation_attempt_at_the_final_mile_if_the_app_is.patch -chore_disable_api_deprecation_warnings_in_nskeyedarchiver.patch feat_add_ability_to_prevent_version_downgrades.patch +refactor_use_non-deprecated_nskeyedarchiver_apis.patch diff --git a/patches/squirrel.mac/chore_disable_api_deprecation_warnings_in_nskeyedarchiver.patch b/patches/squirrel.mac/chore_disable_api_deprecation_warnings_in_nskeyedarchiver.patch deleted file mode 100644 index c4760ca747cc..000000000000 --- a/patches/squirrel.mac/chore_disable_api_deprecation_warnings_in_nskeyedarchiver.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Shelley Vohr -Date: Thu, 22 Jun 2023 12:52:10 +0200 -Subject: chore: disable API deprecation warnings in NSKeyedArchiver - -This should be updated to use the newer APIs. - -Upstream PR at https://github.com/Squirrel/Squirrel.Mac/pull/273 - -diff --git a/Squirrel/SQRLInstaller.m b/Squirrel/SQRLInstaller.m -index f502df2f88424ea902a061adfeb30358daf212e4..a18fedc3e47eb9c8bb7afc42aeab7cef3df742a3 100644 ---- a/Squirrel/SQRLInstaller.m -+++ b/Squirrel/SQRLInstaller.m -@@ -182,14 +182,20 @@ - (SQRLInstallerOwnedBundle *)ownedBundle { - id archiveData = CFBridgingRelease(CFPreferencesCopyValue((__bridge CFStringRef)SQRLInstallerOwnedBundleKey, (__bridge CFStringRef)self.applicationIdentifier, kCFPreferencesCurrentUser, kCFPreferencesCurrentHost)); - if (![archiveData isKindOfClass:NSData.class]) return nil; - -+#pragma clang diagnostic push -+#pragma clang diagnostic ignored "-Wdeprecated-declarations" - SQRLInstallerOwnedBundle *ownedBundle = [NSKeyedUnarchiver unarchiveObjectWithData:archiveData]; - if (![ownedBundle isKindOfClass:SQRLInstallerOwnedBundle.class]) return nil; -+#pragma clang diagnostic pop - - return ownedBundle; - } - - - (void)setOwnedBundle:(SQRLInstallerOwnedBundle *)ownedBundle { -+#pragma clang diagnostic push -+#pragma clang diagnostic ignored "-Wdeprecated-declarations" - NSData *archiveData = (ownedBundle == nil ? nil : [NSKeyedArchiver archivedDataWithRootObject:ownedBundle]); -+#pragma clang diagnostic pop - CFPreferencesSetValue((__bridge CFStringRef)SQRLInstallerOwnedBundleKey, (__bridge CFPropertyListRef)archiveData, (__bridge CFStringRef)self.applicationIdentifier, kCFPreferencesCurrentUser, kCFPreferencesCurrentHost); - CFPreferencesSynchronize((__bridge CFStringRef)self.applicationIdentifier, kCFPreferencesCurrentUser, kCFPreferencesCurrentHost); - } diff --git a/patches/squirrel.mac/refactor_use_non-deprecated_nskeyedarchiver_apis.patch b/patches/squirrel.mac/refactor_use_non-deprecated_nskeyedarchiver_apis.patch new file mode 100644 index 000000000000..c18ba2b778a5 --- /dev/null +++ b/patches/squirrel.mac/refactor_use_non-deprecated_nskeyedarchiver_apis.patch @@ -0,0 +1,50 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Shelley Vohr +Date: Thu, 22 Jun 2023 12:26:24 +0200 +Subject: refactor: use non-deprecated NSKeyedArchiver APIs + +Refs https://chromium-review.googlesource.com/c/chromium/src/+/4628901 + +Several NSKeyedArchiver methods have been deprecated and replaced as of macOS 10.13: + +- unarchiveObjectWithData -> unarchivedObjectOfClass:fromData:error: +- archivedDataWithRootObject -> archivedDataWithRootObject:requiringSecureCoding:error: + +diff --git a/Squirrel/SQRLInstaller.m b/Squirrel/SQRLInstaller.m +index f502df2f88424ea902a061adfeb30358daf212e4..8db6406ec7f0cb51140ea2ee39c04f91626f6e18 100644 +--- a/Squirrel/SQRLInstaller.m ++++ b/Squirrel/SQRLInstaller.m +@@ -182,14 +182,30 @@ - (SQRLInstallerOwnedBundle *)ownedBundle { + id archiveData = CFBridgingRelease(CFPreferencesCopyValue((__bridge CFStringRef)SQRLInstallerOwnedBundleKey, (__bridge CFStringRef)self.applicationIdentifier, kCFPreferencesCurrentUser, kCFPreferencesCurrentHost)); + if (![archiveData isKindOfClass:NSData.class]) return nil; + +- SQRLInstallerOwnedBundle *ownedBundle = [NSKeyedUnarchiver unarchiveObjectWithData:archiveData]; +- if (![ownedBundle isKindOfClass:SQRLInstallerOwnedBundle.class]) return nil; ++ NSError *error; ++ SQRLInstallerOwnedBundle *ownedBundle = [NSKeyedUnarchiver unarchivedObjectOfClass:[SQRLInstallerOwnedBundle class] ++ fromData:archiveData ++ error:&error]; ++ if (error) { ++ NSLog(@"Couldn't unarchive ownedBundle - %@", error.localizedDescription); ++ return nil; ++ } + + return ownedBundle; + } + + - (void)setOwnedBundle:(SQRLInstallerOwnedBundle *)ownedBundle { +- NSData *archiveData = (ownedBundle == nil ? nil : [NSKeyedArchiver archivedDataWithRootObject:ownedBundle]); ++ NSData *archiveData = nil; ++ if (ownedBundle != nil) { ++ NSError *error; ++ archiveData = [NSKeyedArchiver archivedDataWithRootObject:ownedBundle ++ requiringSecureCoding:NO ++ error:&error]; ++ ++ if (error) ++ NSLog(@"Couldn't archive ownedBundle - %@", error.localizedDescription); ++ } ++ + CFPreferencesSetValue((__bridge CFStringRef)SQRLInstallerOwnedBundleKey, (__bridge CFPropertyListRef)archiveData, (__bridge CFStringRef)self.applicationIdentifier, kCFPreferencesCurrentUser, kCFPreferencesCurrentHost); + CFPreferencesSynchronize((__bridge CFStringRef)self.applicationIdentifier, kCFPreferencesCurrentUser, kCFPreferencesCurrentHost); + }