Skip to content

Commit

Permalink
Merge pull request #26 from marcprux/patch-1
Browse files Browse the repository at this point in the history
Make isSVGFormatForData work for small SVG strings
  • Loading branch information
dreampiggy authored Aug 14, 2020
2 parents 1befe3d + 7127ab3 commit db90880
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions SDWebImageSVGCoder/Classes/SDImageSVGCoder.m
Original file line number Diff line number Diff line change
Expand Up @@ -261,15 +261,8 @@ + (BOOL)isSVGFormatForData:(NSData *)data {
if (!data) {
return NO;
}
if (data.length <= 100) {
return NO;
}
// Check end with SVG tag
NSString *testString = [[NSString alloc] initWithData:[data subdataWithRange:NSMakeRange(data.length - 100, 100)] encoding:NSASCIIStringEncoding];
if (![testString containsString:kSVGTagEnd]) {
return NO;
}
return YES;

return [data rangeOfData:[kSVGTagEnd dataUsingEncoding:NSUTF8StringEncoding] options:NSDataSearchBackwards range: NSMakeRange(data.length - MIN(100, data.length), MIN(100, data.length))].location != NSNotFound;
}

@end

0 comments on commit db90880

Please sign in to comment.