main extension for a mimetype
David Faure
dfaure at trolltech.com
Tue Jul 1 06:46:38 PDT 2008
The concept of the "main" extension for a mimetype is missing in shared-mime-info,
(which constitutes a regression compared to our earlier system).
This is needed in one case: when saving a file, using the file dialog. It is a rather common
feature to choose a mimetype in the file dialog "filter" combobox, and to let the application
append the extension to the typed filename.
But for a mimetype that has more than one extension, how do we know which extension should
be used? That's where the concept of the "main" extension is needed.
I tried to make it "the first glob listed for this mimetype", but update-mime-database uses a hash
internally, so the order of the lines in the globs file is unrelated to the order of the globs in the XML,
and this approach is therefore unreliable.
Testcase for this issue: openoffice installs a packages/openoffice.xml file which says
<mime-type type="application/vnd.oasis.opendocument.text">
<sub-class-of type="application/xml"/> [...]
<glob pattern="*.odt" />
<glob pattern="*.fodt" />
</mime-type>
This adds the [strange] extension *.fodt to this mimetype, and due to the hashing in update-mime-database
it appears as the "first" extension for this mimetype, which breaks saving in koffice, people get .fodt files now :)
I see two solutions:
1) fixing update-mime-database to respect the order of the globs [but this is a bit of an undocumented use of that order]
2) adding real support for the "main" extension for a mimetype (which would also remove the need for parsing it
out of the *.foo format). For instance <default-extension name="odt"> or something like that.
--
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).
More information about the xdg
mailing list