diff --git a/Monal/Classes/chatViewController.m b/Monal/Classes/chatViewController.m index 47c31b068..f17f0266f 100644 --- a/Monal/Classes/chatViewController.m +++ b/Monal/Classes/chatViewController.m @@ -2998,7 +2998,7 @@ -(void) loadPreviewWithUrlForRow:(NSIndexPath *) indexPath withResultHandler:(mo return; } //limit to 512KB of html - if(contentLength.intValue > 524288) + if(contentLength.intValue > 65536) { DDLogWarn(@"Now loading preview HTML for %@ with byte range 0-512k...", row.url); [self downloadPreviewWithRow:indexPath usingByterange:YES andResultHandler:resultHandler]; @@ -3038,7 +3038,7 @@ -(void) downloadPreviewWithRow:(NSIndexPath*) indexPath usingByterange:(BOOL) us request.requiresDNSSECValidation = YES; [request setValue:@"facebookexternalhit/1.1" forHTTPHeaderField:@"User-Agent"]; //required on some sites for og tags e.g. youtube if(useByterange) - [request setValue:@"bytes=0-524288" forHTTPHeaderField:@"Range"]; + [request setValue:@"bytes=0-65536" forHTTPHeaderField:@"Range"]; request.timeoutInterval = 10; NSURLSession* session = [HelperTools createEphemeralURLSession]; [[session dataTaskWithRequest:request completionHandler:^(NSData* _Nullable data, NSURLResponse* _Nullable response, NSError* _Nullable error) { @@ -3047,10 +3047,14 @@ -(void) downloadPreviewWithRow:(NSIndexPath*) indexPath usingByterange:(BOOL) us else { NSString* body = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; - NSURL* baseURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@://%@%@", row.url.scheme, row.url.host, row.url.path]]; - MLOgHtmlParser* ogParser = [[MLOgHtmlParser alloc] initWithHtml:body andBaseUrl:baseURL]; + MLOgHtmlParser* ogParser = nil; NSString* text = nil; NSURL* image = nil; + if([body length] <= 65536) + { + NSURL* baseURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@://%@%@", row.url.scheme, row.url.host, row.url.path]]; + ogParser = [[MLOgHtmlParser alloc] initWithHtml:body andBaseUrl:baseURL]; + } if(ogParser != nil) { text = [ogParser getOgTitle];