mirror of
https://github.com/moodle/moodle.git
synced 2025-05-04 15:27:34 +02:00
MDL-13766, fixed mimetype validation.
This commit is contained in:
parent
16f61c701e
commit
2385e6de5b
@ -164,14 +164,14 @@ switch ($action) {
|
|||||||
case 'download':
|
case 'download':
|
||||||
// validate mimetype
|
// validate mimetype
|
||||||
$mimetypes = array();
|
$mimetypes = array();
|
||||||
if (in_array('*', $accepted_types) or $accepted_types == '*') {
|
if ((is_array($accepted_types) and in_array('*', $accepted_types)) or $accepted_types == '*') {
|
||||||
$mimetypes = '*';
|
$mimetypes = '*';
|
||||||
} else {
|
} else {
|
||||||
foreach ($accepted_types as $type) {
|
foreach ($accepted_types as $type) {
|
||||||
$mimetypes[] = mimeinfo('type', $type);
|
$mimetypes[] = mimeinfo('type', $type);
|
||||||
}
|
}
|
||||||
if (!in_array(mimeinfo('type', $saveas_filename), $mimetypes)) {
|
if (!in_array(mimeinfo('type', $saveas_filename), $mimetypes)) {
|
||||||
throw new moodle_exception('invalidfiletype', 'repository', '', mimeinfo('type', $_FILES[$elname]['name']));
|
throw new moodle_exception('invalidfiletype', 'repository', '', mimeinfo('type', $saveas_filename));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user