-
Bug
-
Resolution: Not a bug
-
Minor
-
None
-
4.5
-
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'
|
]
|