Skip to content

[BUG] mime-types can no longer be extended #5834

@line-o

Description

@line-o

Describe the bug

In previous versions users of existdb (at least on v3) were able to overwrite the mime type table to (de-)register mimetypes and also make the database recognise certain file extensions as containing XML data.

When looking at the default mime-types.xml within the repository, the first docblock indicates that this is still possible.
For a user to override the mime-types.xml table one would have to place it directly in the $EXIST_HOME directory.

In my testing this was not possible. I added several new file extensions that should be recognised as XML data when uploading but they were only recognised as binary.

Looking at the actual implementation of MimeTable.java

  • a singleton class
  • with three getInstance methods
  • two of those accept a parameter that allows to override the default mime type definitions
  • there is one call to MimeTable#getInstance(final Path path) in XMLDBStoreTask which is part of exist-ant

Based on this it is safe to say that it is not possible to override the mime table and therefore add XML types that
are not part of the default definitions. Like KML for example.

Expected behavior

The possibility for users to override and extend file extensions and the corresponding mime-types is useful.
Even if we would define all mime types registered with IANA there would still be users having to add custom extensions.
It is not feasible for everyone to build a custom version of exist-db to achieve that.

To Reproduce

  1. place a copy of https://github.com/eXist-db/exist/blob/develop-6.x.x/exist-core/src/main/resources/org/exist/util/mime-types.xml in your $EXIST_HOME folder
  2. Start up exist-db
  3. upload a KML file
  4. even if the upload succeeds the KML file is not recognised as binary and its contents cannot be queried

Example KML file

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
  <Placemark>
    <name>Zürich</name>
    <description>Zürich</description>
    <Point>
      <coordinates>8.55,47.3666667,0</coordinates>
    </Point>
  </Placemark>
</Document>
</kml>

Screenshots

The Java Admin Client even refuses to upload the file at all and throws an excpetion:

Image

Context (please always complete the following information)

  • Build: eXist-6.4.0 (2e41828)
  • Java: 1.8.0_452 (Temurin)
  • OS: Linux 6.10.14-linuxkit (aarch64)

Tested on Docker existdb/existdb-6.4.0 and 7.0.0-SNAPSHOT (d7b9c4a)

Additional context

  • How is eXist-db installed? Docker, built from source
  • Any custom changes in e.g. conf.xml? none

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions