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 - Image MIME resolver should match files against extensions and not only against a magic in their headers
Summary: Image MIME resolver should match files against extensions and not only agains...
Status: CLOSED FIXED
Alias: None
Product: utilities
Classification: Unclassified
Component: Image (show other bugs)
Version: 4.x
Hardware: All All
: P2 blocker (vote)
Assignee: Marian Petras
URL:
Keywords: PERFORMANCE
Depends on:
Blocks: 55701
  Show dependency tree
 
Reported: 2005-03-11 16:33 UTC by Antonin Nebuzelsky
Modified: 2006-03-24 13:02 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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?