simplemagic
simplemagic copied to clipboard
svg is not recognized
I used this svg file https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/410.svg
@Test
public void testSvgBug() throws IOException {
try (InputStream resource = getClass().getResourceAsStream("410.svg")) {
byte[] byteArray = ByteStreams.toByteArray(resource);
ContentInfoUtil contentInfoUtil = new ContentInfoUtil();
ContentInfo match = contentInfoUtil.findMatch(byteArray);
assertThat(match.getContentType()).isEqualTo(ContentType.SVG);
}
}
Seems like there is some issue in the magic.gz file
>>23 search/400 \<svg SVG Scalable Vector Graphics image
!:mime image/svg+xml
well it results in svg is not added to com.j256.simplemagic.entries.MagicEntries#entryList :/
Confirmed, and this should be relatively easy to detect, as it's an XML file that has "<svg" somewhere in the beginning... It can be either the first tag, or a bit later. However, note that if there is a long comment before the "<svg" tag, and this library reads just a bit of the file, it might just consider it as an XML file...
Looking at how much the library reads, I can see that for various files it reads up to 16KB (test available here by using FilterInputStream class ) , so SVG should usually be possible to detect.