diff --git a/Classes/MGMAdinline.m b/Classes/MGMAdinline.m index 9946491..5b7613f 100644 --- a/Classes/MGMAdinline.m +++ b/Classes/MGMAdinline.m @@ -48,13 +48,27 @@ NSString * const MGMAIAllowStrangers = @"MGMAIAllowStrangers"; continue; range.location = linkStartRange.location+linkStartRange.length; range.length = [html length]-range.location; - NSRange linkEndRange = [html rangeOfString:@"<" options:NSCaseInsensitiveSearch range:range]; + NSRange linkEndRange = [html rangeOfString:@"" options:NSCaseInsensitiveSearch range:tagRange]; + if (tagEndRange.location==NSNotFound) + break; + [link replaceCharactersInRange:NSMakeRange(tagStartRange.location, (tagEndRange.location+tagEndRange.length)-tagStartRange.location) withString:@""]; + tagRange.location = tagStartRange.location; + tagRange.length = [link length]-tagRange.location; + } if ([imageExtensions containsObject:[[[[NSURL URLWithString:link] path] pathExtension] lowercaseString]]) { if (shouldScroll==nil) { WebView *webview = (WebView *)[[(id)[[[theContent chat] chatContainer] chatViewController] messageDisplayController] messageView]; @@ -65,6 +79,7 @@ NSString * const MGMAIAllowStrangers = @"MGMAIAllowStrangers"; range.location += [image length]-linkRange.length; range.length = [html length]-range.location; } + [link release]; } else { break; }