catch invalid addresses when loading tracker favicons
This commit is contained in:
parent
6a53f72481
commit
b4cdc74706
|
@ -196,9 +196,11 @@ NSMutableSet * fTrackerIconLoading;
|
||||||
|
|
||||||
- (NSImage *) favIcon
|
- (NSImage *) favIcon
|
||||||
{
|
{
|
||||||
|
id icon = nil;
|
||||||
NSURL * address = [NSURL URLWithString: [(TrackerNode *)[self objectValue] fullAnnounceAddress]];
|
NSURL * address = [NSURL URLWithString: [(TrackerNode *)[self objectValue] fullAnnounceAddress]];
|
||||||
NSString * host = [address host];
|
NSString * host;
|
||||||
|
if ((host = [address host]))
|
||||||
|
{
|
||||||
//don't try to parse ip address
|
//don't try to parse ip address
|
||||||
const BOOL separable = !tr_addressIsIP([host UTF8String]);
|
const BOOL separable = !tr_addressIsIP([host UTF8String]);
|
||||||
|
|
||||||
|
@ -212,12 +214,13 @@ NSMutableSet * fTrackerIconLoading;
|
||||||
else
|
else
|
||||||
baseAddress = [NSString stringWithFormat: @"http://%@", host];
|
baseAddress = [NSString stringWithFormat: @"http://%@", host];
|
||||||
|
|
||||||
id icon = [fTrackerIconCache objectForKey: baseAddress];
|
icon = [fTrackerIconCache objectForKey: baseAddress];
|
||||||
if (!icon && ![fTrackerIconLoading containsObject: baseAddress])
|
if (!icon && ![fTrackerIconLoading containsObject: baseAddress])
|
||||||
{
|
{
|
||||||
[fTrackerIconLoading addObject: baseAddress];
|
[fTrackerIconLoading addObject: baseAddress];
|
||||||
[NSThread detachNewThreadSelector: @selector(loadTrackerIcon:) toTarget: self withObject: baseAddress];
|
[NSThread detachNewThreadSelector: @selector(loadTrackerIcon:) toTarget: self withObject: baseAddress];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (icon && icon != [NSNull null]) ? icon : [NSImage imageNamed: @"FavIcon.png"];
|
return (icon && icon != [NSNull null]) ? icon : [NSImage imageNamed: @"FavIcon.png"];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue