Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-71640

QMimeDatabase: MIME detection issues with alias

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • P4: Low
    • None
    • 5.6
    • Core: Other
    • None
    • Linux/X11

    Description

      I didn't find a good title

      Consider the following MIME definitions:

      <?xml version="1.0" encoding="utf-8"?>
      <mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
        <mime-type type="application/x-ole-storage">
          <magic><!-- higher priority than the parent magic -->
              <match value="abcd" type="string" offset="0:200"/>
          </magic>
        </mime-type>
        <mime-type type="application/msword">
          <sub-class-of type="application/x-ole-storage"/>
          <generic-icon name="x-office-document"/>
          <glob pattern="*.doc"/>
          <alias type="application/vnd.ms-word"/>
          <alias type="application/x-msword"/>
        </mime-type>
        <mime-type type="application/foo.doc">
          <alias type="application/msword"/>
          <alias type="application/vnd.ms-word"/>
          <alias type="application/x-msword"/>
          <glob pattern="*.doc" weight="60"/>
        </mime-type>
      </mime-info>

      And the following file "something.doc"

       

      abcd
      a foo.doc file
      

      Use the "QMimeDatabase::mimeTypeForFileName("something.doc")" result "application/foo.doc"

      Use the "QMimeDatabase::mimeTypeForData(...)" result "application/x-ole-storage"

      Use the "QMimeDatabase::mimeTypeForFileNameAndData("something.doc", ...)" result "application/x-ole-storage"

      Because it is known by alias that "application/foo.doc" is equivalent to "application/msword", "QMimeDatabase::mimeTypeForFileNameAndData" can return better results: "application/foo.doc"

       

      Attachments

        For Gerrit Dashboard: QTBUG-71640
        # Subject Branch Project Status CR V

        Activity

          People

            dfaure_kdab David Faure
            zccrs JiDe Zhang
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes