Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-82859

core_filetypes::core_filetypes() assumes that any type of file will only have a single mime type

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not a bug
    • Icon: Minor Minor
    • None
    • 4.5
    • Libraries
    • None
    • MOODLE_405_STABLE

      Discovered while working MDL-63399.

      Currently core_filetypes::core_filetypes() that any file format can only have one mimetype which is not right. For example, xml format can have two valid mimetypes:

      • application/xml
      • text/xml

      We've came across this issue because the behat_download class validates the downloaded file mime type and in the case of xml files, the actual mimetype coming from finfo():

              $fileextension = 'xml;
              $finfo = new finfo(FILEINFO_MIME_TYPE);
              $actualmimetype = $finfo->buffer($filecontent); // 'text/xml'
      

      ... doesn't match the mime type returned from core_filetypes::get_types()

              $fileextension = 'xml;
              $filetypeinfo = core_filetypes::get_types();
              $expectedmimetype = $filetypeinfo[$fileextension]['type']; // 'application/xml'
      

      This comes from this line. Since both are valid xml mimetypes, the correct would for that function to support multiple mimetypes:

                   'xml' => [
                       'type' => [
                           'application/xml',
                             text/xml
                       ],
                       'icon' => 'markup'
                   ]
      

            dobedobedoh Andrew Lyons
            lameze Simey Lameze
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.