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.
Summary: | Cannot make a declarative MIME resolver check magic headers for only some file extensions | ||
---|---|---|---|
Product: | platform | Reporter: | Jesse Glick <jglick> |
Component: | Filesystems | Assignee: | Petr Nejedly <pnejedly> |
Status: | RESOLVED FIXED | ||
Severity: | blocker | CC: | issues, issues, jtulach |
Priority: | P3 | Keywords: | PERFORMANCE |
Version: | 3.x | ||
Hardware: | All | ||
OS: | All | ||
Issue Type: | DEFECT | Exception Reporter: | |
Bug Depends on: | 18910 | ||
Bug Blocks: | 16191, 117280, 119099 |
Description
Jesse Glick
2003-03-13 15:35:02 UTC
No immediate impact. Clearly not fixable for D - API frozen. This syntax seems to me supported: <file name="manifest2.MF"><![CDATA[<?xml version="1.0"?> <MIME-resolver> <file> <ext name="MF"/> <magic hex="4D616E69666573742D56657273696F6E3A20312E30"/> <resolver mime="text/x-java-jar-manifest"/> </file> </MIME-resolver>]]> </file> <file name="manifest.mf"><![CDATA[<?xml version="1.0"?> <MIME-resolver> <file> <ext name="mf"/> <magic hex="4D616E69666573742D56657273696F6E3A20312E30"/> <resolver mime="text/x-java-jar-manifest"/> </file> </MIME-resolver>]]> </file> <file name="manifest3.txt"><![CDATA[<?xml version="1.0"?> <MIME-resolver> <file> <ext name="txt"/> <magic hex="4D616E69666573742D56657273696F6E3A20312E30"/> <resolver mime="text/x-java-jar-manifest"/> </file> </MIME-resolver>]]> </file> Is it enough ? Your example is broken (need a single XML file), but yes I think it would work to have several <file> elements in a <MIME-resolver> duplicating the magic key. Just ugly, that is all. It works as far as I tested it in unit tests (single XML file would also definitely work). I don't see it so ugly. But I admit that your ant alike syntax is better. It does not work. The semantics of <file>: http://www.netbeans.org/download/dev/javadoc/org-openide-filesystems/org/openide/filesystems/doc-files/resolverDocumentation.html#file "Some of them must match to proceed to the resolver element." This means that I cannot e.g. patch scripting/sh/src/org/netbeans/modules/languages/sh/sh.xml to include: <file> <ext name=""/> <magic hex="23212f62696e2f73680a"/> <!-- "#!/bin/sh\n" --> <resolver mime="text/sh"/> </file> It does not work - *any* file without an extension is treated as a shell script, and *every* other file is opened to look for the magic token. I want an <and> here, not an <or>. Petr, because of fixing #117319 - please look at this issue or reassign back I think that the only logical interpretation of the declarative resolver would be implicit OR of all subelements of the same kind and implicit AND between all present kind groups, that is: <file> <ext name="mf"/> <ext name="MF"/> <ext name="txt"/> <magic hex="4D616E69666573742D56657273696F6E3A20312E30"/> <resolver mime="text/x-java-jar-manifest"/> </file> should be interpreted as (mf || MF || txt) && magic(4D616E69666573742D56657273696F6E3A20312E30). It doesn't make sense to place "AND" between elements of the same kind. It doesn't make sense to place OR between elements of the different kind either (but this is current state). I believe no current resolver depend on the present behavior of or-between-kinds, so it should be safe to change the behavior. The change would be semantically incompatible, technically speaking, though. I'm going to fix this as outlined. Even one test in MIMEResolverImplTest suggests that it is in fact the expected behavior. BTW: The test should be failing, because there was another bug in MIMEResolverImpl (off-by-one when stripping mime type argument), but was passing by accident just because the current behavior is not as described here. Fixed in: core/src/org/netbeans/core/filesystems/MIMEResolverImpl.java,v1.29 core/test/unit/src/org/netbeans/core/filesystems/MIMEResolverImplTest.java,v1.14 core/test/unit/src/org/netbeans/core/filesystems/code-fs.xml,v1.4 core/test/unit/src/org/netbeans/core/filesystems/data-fs.xml,v1.4 A small test added to verify the AND behavior between different rule kinds. |