commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrea Spinelli <>
Subject Re: JMimeMagic (was [fileUpload] file content-type)
Date Wed, 19 Apr 2006 12:25:22 GMT
Jörg Schaible wrote:

>Again I am quite sure, that a lot of SVG documents are not recognized.
>Main problem is that the format specification cannot deal with variable length. See "man
magic" for the format definition. You cannot express, that a file with an XML declaration
followed by a non-empty line with a DOCTYPE declaration for SVG is "image/svg+xml".
>Bottom line: I am no longer sure, if a mime detection based on the definitions of file
magic is really a good idea :-/
Hi everybody!

I see two mixed problems in the post by Joerg:

1. the magic file which is not accurate
2. the magic file format which is not good enough for XML stylesheets

2. facilitates 1.

I think we should not throw away the great deal of information present 
in the magic file, so we should keep magic.xml, but adding the 
possibility of custom matches.

I propose adding a new test, like
        <description>XML SVG</description>
        <test type="custom" offset="0" length="1024" 
class="" />

where implements the interface:

public interface net.sf.jmimemagic.CustomMatcher {
    public boolean match( byte [] sample );

the function match is passed, according to the above example, at most 
1024 bytes from the file starting at byte 0.

If the byte sample matches, the function must return true.  Of course, 
users of jmimemagic Next Generation must include in their classpaths the 
class MyXMLSVGChecker.

Just my two cents

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message