SDWebImage / SDWebImageSVGCoder

A SVG coder plugin for SDWebImage, using Apple's built-in framework
MIT License
103 stars 34 forks source link

Make isSVGFormatForData work for small SVG strings #26

Closed marcprux closed 4 years ago

marcprux commented 4 years ago

The current isSVGFormatForData breaks when the SVG is less than 100 characters, which should be permitted (e.g., "<svg><circle/></svg>" is valid SVG).

dreampiggy commented 4 years ago

This may block the caller queue, if your search SVG contents file size larger than 1MB. Because isSVGFormatForData is called from main queue.

dreampiggy commented 4 years ago

If you want to change, maybe we need to change the same logic in https://github.com/SDWebImage/SDWebImage/blob/master/SDWebImage/Core/NSData%2BImageContentType.m#L76

dreampiggy commented 4 years ago

Merge for now. For SDWebImage Core repo, I'll submit another PR.

dreampiggy commented 4 years ago

Release v1.5.2

marcprux commented 4 years ago

I don't see how it blocks any more than the previous code did … both of them are only checking the last 100 bytes of the NSData for the closing "" tag. The fix simply also permits checking in SVG data that is itself less than 100 bytes.