commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jörg Schaible <Joerg.Schai...@Elsag-Solutions.com>
Subject RE: JMimeMagic (was [fileUpload] file content-type)
Date Wed, 19 Apr 2006 13:17:46 GMT
Hi Andrea,

Andrea Spinelli wrote on Wednesday, April 19, 2006 2:25 PM:

> 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
>     <match>
>         <mimetype>image/svg+xml</mimetype>
>         <extension>svg</extension>
>         <description>XML SVG</description>
>         <test type="custom" offset="0" length="1024"
> class="com.foo.MyXMLSVGChecher" />
>     </match>
> 
> where com.foo.MyXMLSVGChecker 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.

1) It is definitely not possible to built on jmimemagic code because of licencing reasons
2) Although jMimeMagic claims to use an imported magic file itself, its magic.xml misses a
lot of formats (e.g. tiff), that are present in file magic since ages
3) Debug it! The code was definately not designed for speed as one would expect from a utility
that should do such examinations on the fly

- Jörg

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message