From 76583dcf692dacd3fbf98b54e1772726cc830ae9 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sat, 24 Oct 2026 12:34:21 -0700 Subject: [PATCH] Trim whitespace/newline characters from (#2944) This fixes a regression introduced in Sparkle 2.9 when signed feeds were added. In our documentation we have suggested surrounding the release notes URL with newline/whitespace for pretty-print formatting reasons. However now that this bug surfaced, the documentation will be updated to remove the extraneous whitespace. Many developers generating appcasts programmatically or with generate_appcast will not run into this issue. --- Resources/SampleAppcast.xml | 24 ++++++------------------ Sparkle/SUAppcast.m | 3 ++- Sparkle/SUAppcastItem.m | 16 ++++++++-------- Tests/Resources/test-links.xml | 9 +++++++-- 4 files changed, 23 insertions(+), 29 deletions(-) diff --git a/Resources/SampleAppcast.xml b/Resources/SampleAppcast.xml index 6deb818c..d664bab9 100755 --- a/Resources/SampleAppcast.xml +++ b/Resources/SampleAppcast.xml @@ -8,12 +8,8 @@ Version 2.0 (2 bugs fixed; 3 new features) https://sparkle-project.org 2.0 - - https://you.com/app/2.0.html - - - https://you.com/app/changelog.php - + https://you.com/app/2.0.html + https://you.com/app/changelog.php Wed, 09 Jan 2006 19:20:11 +0000 12.0 @@ -23,12 +19,8 @@ Version 1.5 (8 bugs fixed; 2 new features) https://sparkle-project.org 1.5 - - https://you.com/app/1.5.html - - - https://you.com/app/changelog.php?up-to=1.5 - + https://you.com/app/1.5.html + https://you.com/app/changelog.php?up-to=1.5 Wed, 01 Jan 2006 12:20:11 +0000 12.0 @@ -38,12 +30,8 @@ Version 1.4 (5 bugs fixed; 2 new features) https://sparkle-project.org - - https://you.com/app/1.4.html - - - https://you.com/app/changelog.php?up-to=1.4 - + https://you.com/app/1.4.html + https://you.com/app/changelog.php?up-to=1.4 241 1.4 Wed, 25 Dec 2005 12:20:11 +0000 diff --git a/Sparkle/SUAppcast.m b/Sparkle/SUAppcast.m index 9326758d..c9a0c760 100644 --- a/Sparkle/SUAppcast.m +++ b/Sparkle/SUAppcast.m @@ -145,7 +145,8 @@ [dict setObject:descriptionDict forKey:SURSSElementDescription]; } } else if ([name isEqualToString:SUAppcastElementReleaseNotesLink]) { - NSString *releaseNotesLink = node.stringValue; + // Trim whitespace to maintain backwards compatibility + NSString *releaseNotesLink = [node.stringValue stringByTrimmingCharactersInSet:NSCharacterSet.whitespaceAndNewlineCharacterSet]; if (releaseNotesLink != nil) { NSDictionary *attributes = [self attributesOfNode:(NSXMLElement *)node]; diff --git a/Sparkle/SUAppcastItem.m b/Sparkle/SUAppcastItem.m index 29a29a37..a0c95f5c 100644 --- a/Sparkle/SUAppcastItem.m +++ b/Sparkle/SUAppcastItem.m @@ -567,10 +567,10 @@ static NSString *SPUSanitizeUntrustedVersionString(NSString *versionString, NSSt processedInfoURL = [NSURL URLWithString:infoLinkURLString]; } - if ([processedInfoURL.scheme caseInsensitiveCompare:@"http"] == NSOrderedSame || [processedInfoURL.scheme caseInsensitiveCompare:@"https"] == NSOrderedSame) { + if (processedInfoURL != nil && ([processedInfoURL.scheme caseInsensitiveCompare:@"http"] == NSOrderedSame || [processedInfoURL.scheme caseInsensitiveCompare:@"https"] == NSOrderedSame)) { infoURL = processedInfoURL; } else { - SULog(SULogLevelError, @"%@ -%@ Info URL must have a http or https URL scheme.", NSStringFromClass([self class]), NSStringFromSelector(_cmd)); + SULog(SULogLevelError, @"Info URL must have a http or https URL scheme: %@", infoLinkURLString); } } } @@ -622,11 +622,11 @@ static NSString *SPUSanitizeUntrustedVersionString(NSString *versionString, NSSt fileURL = [NSURL URLWithString:fileURLString]; } - if ([fileURL.scheme caseInsensitiveCompare:@"http"] == NSOrderedSame || [fileURL.scheme caseInsensitiveCompare:@"https"] == NSOrderedSame) { + if (fileURL != nil && ([fileURL.scheme caseInsensitiveCompare:@"http"] == NSOrderedSame || [fileURL.scheme caseInsensitiveCompare:@"https"] == NSOrderedSame)) { _fileURL = fileURL; } else { if (error) { - *error = @"File URLs must have a http or https URL scheme"; + *error = [NSString stringWithFormat:@"File URL must have a http or https URL scheme: %@", fileURLString]; } return nil; } @@ -825,10 +825,10 @@ static NSString *SPUSanitizeUntrustedVersionString(NSString *versionString, NSSt } else { url = [NSURL URLWithString:releaseNotesString]; } - if ([url.scheme caseInsensitiveCompare:@"http"] == NSOrderedSame || [url.scheme caseInsensitiveCompare:@"https"] == NSOrderedSame) { + if (url != nil && ([url.scheme caseInsensitiveCompare:@"http"] == NSOrderedSame || [url.scheme caseInsensitiveCompare:@"https"] == NSOrderedSame)) { _releaseNotesURL = url; } else { - SULog(SULogLevelError, @"Release notes must have a http or https URL scheme."); + SULog(SULogLevelError, @"Release notes must have a http or https URL scheme: %@", releaseNotesString); _releaseNotesURL = nil; } } else if ([_itemDescription hasPrefix:@"http://"] || [_itemDescription hasPrefix:@"https://"]) { // if the description starts with http:// or https:// use that. @@ -857,10 +857,10 @@ static NSString *SPUSanitizeUntrustedVersionString(NSString *versionString, NSSt } else { url = [NSURL URLWithString:fullReleaseNotesString]; } - if ([url.scheme caseInsensitiveCompare:@"http"] == NSOrderedSame || [url.scheme caseInsensitiveCompare:@"https"] == NSOrderedSame) { + if (url != nil && ([url.scheme caseInsensitiveCompare:@"http"] == NSOrderedSame || [url.scheme caseInsensitiveCompare:@"https"] == NSOrderedSame)) { _fullReleaseNotesURL = url; } else { - SULog(SULogLevelError, @"Full release notes must have a http or https URL scheme."); + SULog(SULogLevelError, @"Full release notes must have a http or https URL scheme: %@", fullReleaseNotesString); _fullReleaseNotesURL = nil; } } else { diff --git a/Tests/Resources/test-links.xml b/Tests/Resources/test-links.xml index 4b1ebd5a..622b0a99 100644 --- a/Tests/Resources/test-links.xml +++ b/Tests/Resources/test-links.xml @@ -13,8 +13,13 @@ Version 2.0 Sat, 26 Jul 2014 15:20:12 +0000 - http://sparkle-project.org/notes/relnote-2.0.txt - http://sparkle-project.org/fullnotes.txt + + + http://sparkle-project.org/notes/relnote-2.0.txt + + + http://sparkle-project.org/fullnotes.txt + http://sparkle-project.org