mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-23434 Added string_exists check to avoid notices for mimetypes without full names
This commit is contained in:
parent
ee15123074
commit
f954e12ea8
1 changed files with 7 additions and 2 deletions
|
@ -66,6 +66,7 @@ class repository_upload extends repository {
|
||||||
|
|
||||||
$fs = get_file_storage();
|
$fs = get_file_storage();
|
||||||
$browser = get_file_browser();
|
$browser = get_file_browser();
|
||||||
|
$sm = get_string_manager();
|
||||||
|
|
||||||
if ($record->filepath !== '/') {
|
if ($record->filepath !== '/') {
|
||||||
$record->filepath = file_correct_filepath($record->filepath);
|
$record->filepath = file_correct_filepath($record->filepath);
|
||||||
|
@ -85,8 +86,12 @@ class repository_upload extends repository {
|
||||||
|
|
||||||
if ($this->mimetypes != '*') {
|
if ($this->mimetypes != '*') {
|
||||||
// check filetype
|
// check filetype
|
||||||
if (!in_array(mimeinfo('type', $_FILES[$elname]['name']), $this->mimetypes)) {
|
$filemimetype = mimeinfo('type', $_FILES[$elname]['name']);
|
||||||
throw new moodle_exception('invalidfiletype', 'repository', '', get_string(mimeinfo('type', $_FILES[$elname]['name']), 'mimetypes'));
|
if (!in_array($filemimetype, $this->mimetypes)) {
|
||||||
|
if ($sm->string_exists($filemimetype, 'mimetypes')) {
|
||||||
|
$filemimetype = get_string($filemimetype, 'mimetypes');
|
||||||
|
}
|
||||||
|
throw new moodle_exception('invalidfiletype', 'repository', '', $filemimetype);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue