Skip to content

Commit

Permalink
fixed crashing issues when received malformed image URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
psychs committed Mar 4, 2011
1 parent f31ddc3 commit a8ac40c
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions Classes/Views/Log/ImageURLParser.m
Expand Up @@ -176,7 +176,7 @@ + (NSString*)imageURLForURL:(NSString*)url
}
}
else if ([host hasSuffix:@"pikubo.jp"]) {
if ([path hasPrefix:@"/photo/"]) {
if ([path hasPrefix:@"/photo/"] && path.length >= 29) {
path = [path substringWithRange:NSMakeRange(7, 22)];
return [NSString stringWithFormat:@"http://pikubo.jp/p/p/%@", path];
}
Expand All @@ -188,18 +188,21 @@ + (NSString*)imageURLForURL:(NSString*)url
}
}
else if ([host hasSuffix:@".ficia.com"]) {
NSString* fragment = u.fragment;
NSString* user = [host substringToIndex:host.length - 10];
if (path.length > 60) {
if ([path hasPrefix:@"/pl/album-photo/"]) {
NSString* s = [path substringFromIndex:53];
return [NSString stringWithFormat:@"http://%@.pst.ficia.com/p/%@.jpg", user, s];
int subdomainLen = host.length - 10;
if (subdomainLen > 0) {
NSString* user = [host substringToIndex:subdomainLen];
NSString* fragment = u.fragment;
if (path.length > 60) {
if ([path hasPrefix:@"/pl/album-photo/"]) {
NSString* s = [path substringFromIndex:53];
return [NSString stringWithFormat:@"http://%@.pst.ficia.com/p/%@.jpg", user, s];
}
}
}
else if (fragment.length > 60) {
if ([fragment hasPrefix:@"album-photo/"]) {
NSString* s = [fragment substringFromIndex:49];
return [NSString stringWithFormat:@"http://%@.pst.ficia.com/p/%@.jpg", user, s];
else if (fragment.length > 60) {
if ([fragment hasPrefix:@"album-photo/"]) {
NSString* s = [fragment substringFromIndex:49];
return [NSString stringWithFormat:@"http://%@.pst.ficia.com/p/%@.jpg", user, s];
}
}
}
}
Expand Down

0 comments on commit a8ac40c

Please sign in to comment.