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

QMimeDatabase: MIME detection issues with alias

XMLWordPrintable

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

      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"

       

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

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

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes