mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-22 04:30:47 +00:00
Fix updating not working the first time if bundle ID ends with ".service" or other problematic extensions (#2909)
This is a continuation of #2882. This issue was brought up in #2907 where .service bundles were also impacted.
This commit is contained in:
1 file changed
+18
-8
Vendored
+18
-8
@@ -18,14 +18,24 @@ static NSTimeInterval OLD_ITEM_DELETION_INTERVAL = 86400 * 10; // 10 days
|
||||
|
||||
+ (NSString *)_cachePathForCacheDirectory:(NSURL *)cacheURL bundleIdentifier:(NSString *)bundleIdentifier SPU_OBJC_DIRECT
|
||||
{
|
||||
// If an app has an ill-formed bundle identifier that ends with ".app" we will append ".sparkle" to it
|
||||
// so that the cache directory doesn't look like an app bundle directory, which can cause other systematic issues
|
||||
// https://github.com/sparkle-project/Sparkle/discussions/2881
|
||||
NSString *appCacheIdentifier;
|
||||
if ([bundleIdentifier hasSuffix:@".app"] || [bundleIdentifier hasSuffix:@".APP"]) {
|
||||
appCacheIdentifier = [bundleIdentifier stringByAppendingString:@".sparkle"];
|
||||
} else {
|
||||
appCacheIdentifier = bundleIdentifier;
|
||||
NSString *appCacheIdentifier = bundleIdentifier;
|
||||
{
|
||||
// If an app has an ill-formed bundle identifier that ends with ".app" or ".service"
|
||||
// or anything similarly problematic, we will append ".sparkle" to it
|
||||
// so that the cache directory doesn't look like a protected bundle directory,
|
||||
// which can cause other systematic issues
|
||||
// https://github.com/sparkle-project/Sparkle/discussions/2881
|
||||
NSArray<NSString *> *problematicBundleIdentifierExtensions = @[@".app", @".service", @".xpc", @".appex", @".bundle", @".plugin", @".saver", @".kext"];
|
||||
|
||||
// Transforming the bundle identifier into a lowercased variant for suffix comparison
|
||||
// rather than case-insensitive comparing the pathExtension (which may return "" for ".app")
|
||||
NSString *lowercasedBundleIdentifier = bundleIdentifier.lowercaseString;
|
||||
for (NSString *badExtension in problematicBundleIdentifierExtensions) {
|
||||
if ([lowercasedBundleIdentifier hasSuffix:badExtension]) {
|
||||
appCacheIdentifier = [bundleIdentifier stringByAppendingString:@".sparkle"];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NSString *resultPath = [[[cacheURL URLByAppendingPathComponent:appCacheIdentifier isDirectory:YES] URLByAppendingPathComponent:@SPARKLE_BUNDLE_IDENTIFIER isDirectory:YES] path];
|
||||
|
||||
Reference in new issue
Block a user