MDL-13766, fixed mimetype validation.

This commit is contained in:
Dongsheng Cai 2010-07-06 07:28:03 +00:00
parent 16f61c701e
commit 2385e6de5b

View File

@ -164,14 +164,14 @@ switch ($action) {
case 'download':
// validate mimetype
$mimetypes = array();
if (in_array('*', $accepted_types) or $accepted_types == '*') {
if ((is_array($accepted_types) and in_array('*', $accepted_types)) or $accepted_types == '*') {
$mimetypes = '*';
} else {
foreach ($accepted_types as $type) {
$mimetypes[] = mimeinfo('type', $type);
}
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));
}
}