mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-27 05:04:27 +00:00
Merge commit '60727bffa53ebfbfaf701575904847827bc1656a' into ui-separation-and-xpc
* commit '60727bffa53ebfbfaf701575904847827bc1656a': Log key read failure Formatting Escape + as well Escape profile URLs better Special case for .tar.gz extension Inline release notes if they don't look like a standalone HTML document Simplify release notes link check Feed formatting
This commit is contained in:
commit
415b4fe164
6 files changed
+80
-23
No files matched your search
Vendored
+8
-1
@@ -697,6 +697,13 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
return [self.updaterSettings sendsSystemProfile];
|
||||
}
|
||||
|
||||
static NSString *escapeURLComponent(NSString *str) {
|
||||
return [[[[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
|
||||
stringByReplacingOccurrencesOfString:@"=" withString:@"%3d"]
|
||||
stringByReplacingOccurrencesOfString:@"&" withString:@"%26"]
|
||||
stringByReplacingOccurrencesOfString:@"+" withString:@"%2b"];
|
||||
}
|
||||
|
||||
// Precondition: The feed URL should be valid
|
||||
- (NSURL * _Nullable)parameterizedFeedURL
|
||||
{
|
||||
@@ -734,7 +741,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
// Build up the parameterized URL.
|
||||
NSMutableArray *parameterStrings = [NSMutableArray array];
|
||||
for (NSDictionary *currentProfileInfo in parameters) {
|
||||
[parameterStrings addObject:[NSString stringWithFormat:@"%@=%@", [[[currentProfileInfo objectForKey:@"key"] description] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding], [[[currentProfileInfo objectForKey:@"value"] description] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
|
||||
[parameterStrings addObject:[NSString stringWithFormat:@"%@=%@", escapeURLComponent([[currentProfileInfo objectForKey:@"key"] description]), escapeURLComponent([[currentProfileInfo objectForKey:@"value"] description])]];
|
||||
}
|
||||
|
||||
NSString *separatorCharacter = @"?";
|
||||
|
||||
Vendored
+6
-1
@@ -144,7 +144,12 @@
|
||||
if (!keyPath) {
|
||||
return nil;
|
||||
}
|
||||
return [NSString stringWithContentsOfFile:keyPath encoding:NSASCIIStringEncoding error:nil];
|
||||
NSError *error = nil;
|
||||
key = [NSString stringWithContentsOfFile:keyPath encoding:NSASCIIStringEncoding error:&error];
|
||||
if (error) {
|
||||
SULog(SULogLevelError, @"Error loading %@: %@", keyPath, error);
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
- (NSString * _Nullable)publicDSAKeyFileKey
|
||||
|
||||
Vendored
+4
-4
@@ -44,8 +44,8 @@ void SULog(SULogLevel level, NSString *format, ...)
|
||||
// Act the same way os_log() does; don't log to stderr if a terminal device is attached
|
||||
if (!isatty(STDERR_FILENO)) {
|
||||
options |= ASL_OPT_STDERR;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
NSString *displayName = [[NSFileManager defaultManager] displayNameAtPath:mainBundle.bundlePath];
|
||||
client = asl_open([displayName stringByAppendingString:@" [Sparkle]"].UTF8String, SPARKLE_BUNDLE_IDENTIFIER, options);
|
||||
queue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL);
|
||||
@@ -78,10 +78,10 @@ void SULog(SULogLevel level, NSString *format, ...)
|
||||
// See docs for OS_LOG_TYPE_ERROR
|
||||
os_log_error(logger, "%{public}@", logMessage);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#pragma clang diagnostic pop
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise use ASL
|
||||
// Make sure we do not async, because if we async, the log may not be delivered deterministically
|
||||
|
||||
Vendored
+13
-6
@@ -61,7 +61,7 @@ static NSMutableDictionary *sharedUpdaters = nil;
|
||||
{
|
||||
self = [super init];
|
||||
if (bundle == nil) bundle = [NSBundle mainBundle];
|
||||
|
||||
|
||||
id updater = [sharedUpdaters objectForKey:[NSValue valueWithNonretainedObject:bundle]];
|
||||
if (updater)
|
||||
{
|
||||
@@ -79,7 +79,7 @@ static NSMutableDictionary *sharedUpdaters = nil;
|
||||
// See -[SUUpdater _standardUserDriverRequestsPathToRelaunch] and -[SUUpdater _pathToRelaunchForUpdater:] implemented below which resolves this
|
||||
_userDriver = [[SPUStandardUserDriver alloc] initWithHostBundle:bundle delegate:self];
|
||||
_updater = [[SPUUpdater alloc] initWithHostBundle:bundle applicationBundle:bundle userDriver:_userDriver delegate:self];
|
||||
|
||||
|
||||
NSError *updaterError = nil;
|
||||
if (![_updater startUpdater:&updaterError]) {
|
||||
SULog(SULogLevelError, @"Error: Failed to start updater with error: %@", updaterError);
|
||||
@@ -185,7 +185,7 @@ static NSMutableDictionary *sharedUpdaters = nil;
|
||||
{
|
||||
[self.updater checkForUpdates];
|
||||
}
|
||||
|
||||
|
||||
- (BOOL)validateMenuItem:(NSMenuItem *)item
|
||||
{
|
||||
if ([item action] == @selector(checkForUpdates:)) {
|
||||
@@ -225,7 +225,7 @@ static NSMutableDictionary *sharedUpdaters = nil;
|
||||
|
||||
self.loggedInstallUpdatesIfAvailableWarning = YES;
|
||||
}
|
||||
|
||||
|
||||
[self checkForUpdatesInBackground];
|
||||
}
|
||||
|
||||
@@ -357,6 +357,13 @@ static NSMutableDictionary *sharedUpdaters = nil;
|
||||
}
|
||||
}
|
||||
|
||||
static NSString *escapeURLComponent(NSString *str) {
|
||||
return [[[[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
|
||||
stringByReplacingOccurrencesOfString:@"=" withString:@"%3d"]
|
||||
stringByReplacingOccurrencesOfString:@"&" withString:@"%26"]
|
||||
stringByReplacingOccurrencesOfString:@"+" withString:@"%2b"];
|
||||
}
|
||||
|
||||
- (BOOL)updater:(SPUUpdater *)__unused updater shouldPostponeRelaunchForUpdate:(SUAppcastItem *)item untilInvokingBlock:(void (^)(void))installHandler
|
||||
{
|
||||
BOOL shouldPostponeRelaunch = NO;
|
||||
@@ -368,9 +375,9 @@ static NSMutableDictionary *sharedUpdaters = nil;
|
||||
|
||||
// This invocation will retain self, but this instance is kept alive forever by our singleton pattern anyway
|
||||
[invocation setTarget:self];
|
||||
|
||||
|
||||
self.postponedInstallHandler = installHandler;
|
||||
|
||||
|
||||
shouldPostponeRelaunch = [self.delegate updater:self shouldPostponeRelaunchForUpdate:item untilInvoking:invocation];
|
||||
}
|
||||
|
||||
|
||||
@@ -119,14 +119,45 @@ class ArchiveItem: CustomStringConvertible {
|
||||
return (self.archiveFileAttributes[.size] as! NSNumber).int64Value;
|
||||
}
|
||||
|
||||
var releaseNotesPath : URL {
|
||||
let basename = self.archivePath.deletingPathExtension();
|
||||
private var releaseNotesPath : URL? {
|
||||
var basename = self.archivePath.deletingPathExtension();
|
||||
if basename.pathExtension == "tar" { // tar.gz
|
||||
basename = basename.deletingPathExtension();
|
||||
}
|
||||
let releaseNotes = basename.appendingPathExtension("html");
|
||||
if !FileManager.default.fileExists(atPath: releaseNotes.path) {
|
||||
return nil;
|
||||
}
|
||||
return releaseNotes;
|
||||
}
|
||||
|
||||
private func getReleaseNotesAsHTMLFragment(_ path: URL) -> String? {
|
||||
if let html = try? String(contentsOf: path) {
|
||||
if html.utf8.count < 1000 &&
|
||||
!html.localizedCaseInsensitiveContains("<!DOCTYPE") &&
|
||||
!html.localizedCaseInsensitiveContains("<body") {
|
||||
return html;
|
||||
}
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
var releaseNotesHTML : String? {
|
||||
if let path = self.releaseNotesPath {
|
||||
return self.getReleaseNotesAsHTMLFragment(path);
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
var releaseNotesURL : URL? {
|
||||
guard let escapedFilename = self.releaseNotesPath.lastPathComponent.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) else {
|
||||
guard let path = self.releaseNotesPath else {
|
||||
return nil;
|
||||
}
|
||||
// The file is already used as inline description
|
||||
if self.getReleaseNotesAsHTMLFragment(path) != nil {
|
||||
return nil;
|
||||
}
|
||||
guard let escapedFilename = path.lastPathComponent.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) else {
|
||||
return nil;
|
||||
}
|
||||
if let relative = self.feedURL {
|
||||
|
||||
@@ -23,6 +23,7 @@ func findOrCreateElement(name: String, parent: XMLElement) -> XMLElement {
|
||||
return element;
|
||||
}
|
||||
let element = XMLElement(name: name);
|
||||
linebreak(parent);
|
||||
parent.addChild(element);
|
||||
return element;
|
||||
}
|
||||
@@ -69,7 +70,9 @@ func writeAppcast(appcastDestPath: URL, updates: [ArchiveItem]) throws {
|
||||
channel = channelNodes[0] as! XMLElement;
|
||||
} else {
|
||||
channel = XMLElement(name: "channel");
|
||||
linebreak(channel);
|
||||
channel.addChild(XMLElement.element(withName: "title", stringValue: appBaseName) as! XMLElement);
|
||||
linebreak(root);
|
||||
root.addChild(channel);
|
||||
}
|
||||
|
||||
@@ -102,6 +105,13 @@ func writeAppcast(appcastDestPath: URL, updates: [ArchiveItem]) throws {
|
||||
item.addChild(XMLElement.element(withName: "pubDate", stringValue: update.pubDate) as! XMLElement);
|
||||
}
|
||||
|
||||
if let html = update.releaseNotesHTML {
|
||||
let descElement = findOrCreateElement(name: "description", parent: item);
|
||||
let cdata = XMLNode(kind:.text, options:.nodeIsCDATA);
|
||||
cdata.stringValue = html;
|
||||
descElement.setChildren([cdata]);
|
||||
}
|
||||
|
||||
var minVer = findElement(name: "sparkle:minimumSystemVersion", parent: item);
|
||||
if nil == minVer {
|
||||
minVer = XMLElement.element(withName: "sparkle:minimumSystemVersion", uri: sparkleNS) as? XMLElement;
|
||||
@@ -111,16 +121,13 @@ func writeAppcast(appcastDestPath: URL, updates: [ArchiveItem]) throws {
|
||||
minVer?.setChildren([text(update.minimumSystemVersion)]);
|
||||
|
||||
let relElement = findElement(name: "sparkle:releaseNotesLink", parent: item);
|
||||
if nil == relElement {
|
||||
if FileManager.default.fileExists(atPath: update.releaseNotesPath.path) {
|
||||
if let url = update.releaseNotesURL {
|
||||
if nil == relElement {
|
||||
linebreak(item);
|
||||
item.addChild(XMLElement.element(withName:"sparkle:releaseNotesLink", stringValue: (update.releaseNotesURL?.absoluteString)!) as! XMLElement);
|
||||
}
|
||||
} else {
|
||||
if !FileManager.default.fileExists(atPath: update.releaseNotesPath.path) {
|
||||
let childIndex = relElement?.index;
|
||||
item.removeChild(at: childIndex!);
|
||||
item.addChild(XMLElement.element(withName:"sparkle:releaseNotesLink", stringValue: url.absoluteString) as! XMLElement);
|
||||
}
|
||||
} else if let childIndex = relElement?.index {
|
||||
item.removeChild(at: childIndex);
|
||||
}
|
||||
|
||||
var enclosure = findElement(name: "enclosure", parent: item);
|
||||
|
||||
Reference in new issue
Block a user