mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-30 05:28:50 +00:00
Pass text encoding and MIME type to user driver for release notes
This fixes issues where the user driver may not be displaying release notes properly because it doesn't know what kind of data was downloaded (eg: html vs plain text).
This commit is contained in:
1 parent
085724322f
commit
65d78d5129
16 files changed
+177
-28
No files matched your search
@@ -120,13 +120,20 @@
|
||||
});
|
||||
}
|
||||
|
||||
- (void)displayReleaseNotes:(NSData *)releaseNotes
|
||||
- (void)displayHTMLReleaseNotes:(NSData *)releaseNotes
|
||||
{
|
||||
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithHTML:releaseNotes documentAttributes:NULL];
|
||||
fprintf(stderr, "Release notes:\n");
|
||||
fprintf(stderr, "%s\n", attributedString.string.UTF8String);
|
||||
}
|
||||
|
||||
- (void)displayPlainTextReleaseNotes:(NSData *)releaseNotes encoding:(NSStringEncoding)encoding
|
||||
{
|
||||
NSString *string = [[NSString alloc] initWithData:releaseNotes encoding:encoding];
|
||||
fprintf(stderr, "Release notes:\n");
|
||||
fprintf(stderr, "%s\n", string.UTF8String);
|
||||
}
|
||||
|
||||
- (void)showUpdateWithAppcastItem:(SUAppcastItem *)appcastItem updateAdjective:(NSString *)updateAdjective
|
||||
{
|
||||
if (self.verbose) {
|
||||
@@ -135,7 +142,7 @@
|
||||
if (appcastItem.itemDescription != nil) {
|
||||
NSData *descriptionData = [appcastItem.itemDescription dataUsingEncoding:NSUTF8StringEncoding];
|
||||
if (descriptionData != nil) {
|
||||
[self displayReleaseNotes:descriptionData];
|
||||
[self displayHTMLReleaseNotes:descriptionData];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -174,11 +181,21 @@
|
||||
});
|
||||
}
|
||||
|
||||
- (void)showUpdateReleaseNotes:(NSData *)releaseNotes
|
||||
- (void)showUpdateReleaseNotesWithData:(NSData *)releaseNotesData textEncodingName:(NSString * _Nullable)textEncodingName MIMEType:(NSString * _Nullable)MIMEType
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (self.verbose) {
|
||||
[self displayReleaseNotes:releaseNotes];
|
||||
if ([MIMEType isEqualToString:@"text/plain"]) {
|
||||
NSStringEncoding encoding;
|
||||
if (textEncodingName == nil) {
|
||||
encoding = NSUTF8StringEncoding;
|
||||
} else {
|
||||
encoding = CFStringConvertEncodingToNSStringEncoding(CFStringConvertIANACharSetNameToEncoding((CFStringRef)textEncodingName));
|
||||
}
|
||||
[self displayPlainTextReleaseNotes:releaseNotesData encoding:encoding];
|
||||
} else {
|
||||
[self displayHTMLReleaseNotes:releaseNotesData];
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user