Fix HTTP scheme for RSS Feed links

This commit is contained in:
relikd
2019-09-14 13:42:58 +02:00
parent 0331f8ca59
commit 994cbd29c2
5 changed files with 2579 additions and 4 deletions

View File

@@ -28,7 +28,7 @@
- (NSString *)rsxml_stringByDecodingHTMLEntities;
- (nonnull NSString *)rsxml_md5HashString;
- (nullable NSString *)absoluteURLWithBase:(nonnull NSURL *)baseURL;
- (nullable NSString *)absoluteURLWithBase:(nullable NSURL *)baseURL;
@end

View File

@@ -51,8 +51,11 @@
return [NSString stringWithFormat:@"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], bytes[6], bytes[7], bytes[8], bytes[9], bytes[10], bytes[11], bytes[12], bytes[13], bytes[14], bytes[15]];
}
- (NSString *)absoluteURLWithBase:(NSURL *)baseURL {
if (baseURL && ![[self lowercaseString] hasPrefix:@"http"]) {
- (NSString *)absoluteURLWithBase:(nullable NSURL *)baseURL {
// Update links that have no scheme.
if (![[NSURL URLWithString:self] scheme]) {
// baseURL is only nil for feed links, not for article links!
if (!baseURL) baseURL = [NSURL URLWithString:@"http://"];
NSURL *resolvedURL = [NSURL URLWithString:self relativeToURL:baseURL];
if (resolvedURL.absoluteString) {
return resolvedURL.absoluteString;

View File

@@ -191,7 +191,7 @@ static NSString *kRDFAboutKey = @"rdf:about";
switch (len) {
case 4:
if (EqualBytes(localName, "link", 4)) {
self.parsedFeed.link = SAXParser.currentStringWithTrimmedWhitespace;
self.parsedFeed.link = [SAXParser.currentStringWithTrimmedWhitespace absoluteURLWithBase:nil];
self.baseURL = [NSURL URLWithString:self.parsedFeed.link];
}
return;