Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

svg is not recognized #57

Open
Loki-Afro opened this issue Oct 26, 2018 · 1 comment
Open

svg is not recognized #57

Loki-Afro opened this issue Oct 26, 2018 · 1 comment

Comments

@Loki-Afro
Copy link

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 :/

@AndroidDeveloperLB
Copy link

AndroidDeveloperLB commented Jul 14, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants