Skip to content

Commit

Permalink
MDL-23434 Added string_exists check to avoid notices for mimetypes wi…
Browse files Browse the repository at this point in the history
…thout full names
  • Loading branch information
moodler committed Jul 22, 2010
1 parent ee15123 commit f954e12
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions repository/upload/lib.php
Expand Up @@ -66,6 +66,7 @@ public function upload() {

$fs = get_file_storage();
$browser = get_file_browser();
$sm = get_string_manager();

if ($record->filepath !== '/') {
$record->filepath = file_correct_filepath($record->filepath);
Expand All @@ -85,8 +86,12 @@ public function upload() {

if ($this->mimetypes != '*') {
// check filetype
if (!in_array(mimeinfo('type', $_FILES[$elname]['name']), $this->mimetypes)) {
throw new moodle_exception('invalidfiletype', 'repository', '', get_string(mimeinfo('type', $_FILES[$elname]['name']), 'mimetypes'));
$filemimetype = mimeinfo('type', $_FILES[$elname]['name']);
if (!in_array($filemimetype, $this->mimetypes)) {
if ($sm->string_exists($filemimetype, 'mimetypes')) {
$filemimetype = get_string($filemimetype, 'mimetypes');
}
throw new moodle_exception('invalidfiletype', 'repository', '', $filemimetype);
}
}

Expand Down

0 comments on commit f954e12

Please sign in to comment.