Fix the image format detection for smaller SVG which less than 100 Bytes.

This commit is contained in:
DreamPiggy 2020-08-15 18:50:40 +08:00
parent b483ec2959
commit f9a089d437
1 changed files with 3 additions and 6 deletions

View File

@ -74,12 +74,9 @@
}
}
case 0x3C: {
if (data.length > 100) {
// Check end with SVG tag
NSString *testString = [[NSString alloc] initWithData:[data subdataWithRange:NSMakeRange(data.length - 100, 100)] encoding:NSASCIIStringEncoding];
if ([testString containsString:kSVGTagEnd]) {
return SDImageFormatSVG;
}
// Check end with SVG tag
if ([data rangeOfData:[kSVGTagEnd dataUsingEncoding:NSUTF8StringEncoding] options:NSDataSearchBackwards range: NSMakeRange(data.length - MIN(100, data.length), MIN(100, data.length))].location != NSNotFound) {
return SDImageFormatSVG;
}
}
}