This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 56290

Summary: Image MIME resolver should match files against extensions and not only against a magic in their headers
Product: utilities Reporter: Antonin Nebuzelsky <anebuzelsky>
Component: ImageAssignee: Marian Petras <mpetras>
Status: CLOSED FIXED    
Severity: blocker CC: issues, jtulach
Priority: P2 Keywords: PERFORMANCE
Version: 4.x   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:
Bug Depends on:    
Bug Blocks: 55701    

Description Antonin Nebuzelsky 2005-03-11 16:33:06 UTC
The MIME resolver definition file org-netbeans-modules-image-mime-resolver.xml
contains various definitions for image files, but only according to their magic
string, e.g:

    <file>
        <magic hex="424d"/>
        <resolver mime="image/bmp"/>
    </file>

This is very bad, because it forces MIME resolver to open almost every file it
comes across and look for the magic in it. This is too much overhead and I don't
see any viable reason for it. Why the hell do we need to recognize BMP file
which is named as something else then .bmp???

If there is no real reason for this, the contents of the XML should be changed
to something like this:

<MIME-resolver>
    <file>
        <ext name="gif">
        <magic hex="47494638"/>
        <resolver mime="image/gif"/>
    </file>
    <file>
        <ext name="jpg">
        <ext name="jpeg">
        <magic hex="ffd8ffe0"/>
        <resolver mime="image/jpeg"/>
    </file>
    <file>
        <ext name="png">
        <magic hex="89504e47"/>
        <resolver mime="image/png"/>
    </file>
    <file>
        <ext name="bmp">
        <magic hex="424d"/>
        <resolver mime="image/bmp"/>
    </file>
</MIME-resolver>
Comment 1 Marian Petras 2005-03-11 16:41:13 UTC
What's wrong? There is no magic in the file's headers.

Maybe you just wanted to write

   "Image MIME resolver is too slow" ?
Comment 2 Marian Petras 2005-03-11 16:43:14 UTC
Sorry, I did not notice the description
(as the e-mail notification format has changed since the SourceCast upgrade).

Accepted.
Comment 3 Marian Petras 2005-03-12 18:19:59 UTC
Fixed in the trunk.

I completely turned off looking at files' headers.

Modified file:

    image/src/org/netbeans/modules/image/mime-resolver.xml   (1.5)

Diff:
http://image.netbeans.org/source/browse/image/src/org/netbeans/modules/image/mime-resolver.xml?r1=1.4&r2=1.5&diff_format=u
Comment 4 Marian Petras 2005-03-12 18:20:58 UTC
FYI: NetBeans source code contains several (maybe many) PNG files having
extension .gif.
Comment 5 Antonin Nebuzelsky 2005-03-23 13:58:59 UTC
Verified.

> FYI: NetBeans source code contains several (maybe many) PNG files having
extension .gif.

Could you, please, file defects against the modules which do so?