diff --git a/Sparkle/SPULocalCacheDirectory.m b/Sparkle/SPULocalCacheDirectory.m index 0a2753d7..974abb16 100644 --- a/Sparkle/SPULocalCacheDirectory.m +++ b/Sparkle/SPULocalCacheDirectory.m @@ -18,7 +18,17 @@ static NSTimeInterval OLD_ITEM_DELETION_INTERVAL = 86400 * 10; // 10 days + (NSString *)_cachePathForCacheDirectory:(NSURL *)cacheURL bundleIdentifier:(NSString *)bundleIdentifier SPU_OBJC_DIRECT { - NSString *resultPath = [[[cacheURL URLByAppendingPathComponent:bundleIdentifier isDirectory:YES] URLByAppendingPathComponent:@SPARKLE_BUNDLE_IDENTIFIER isDirectory:YES] path]; + // 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 *resultPath = [[[cacheURL URLByAppendingPathComponent:appCacheIdentifier isDirectory:YES] URLByAppendingPathComponent:@SPARKLE_BUNDLE_IDENTIFIER isDirectory:YES] path]; assert(resultPath != nil); return resultPath; @@ -90,6 +100,8 @@ static NSTimeInterval OLD_ITEM_DELETION_INTERVAL = 86400 * 10; // 10 days if ([templateString getFileSystemRepresentation:buffer maxLength:sizeof(buffer)]) { if (mkdtemp(buffer) != NULL) { return [[NSString alloc] initWithUTF8String:buffer]; + } else { + SULog(SULogLevelError, @"Failed to create templated intermediate cache directory using mkdtemp() with error: %d", errno); } } return nil;