diff --git a/backup/converter/moodle1/lib.php b/backup/converter/moodle1/lib.php index 4fd0e1b2a06..4df141ff61e 100644 --- a/backup/converter/moodle1/lib.php +++ b/backup/converter/moodle1/lib.php @@ -642,7 +642,9 @@ class moodle1_converter extends base_converter { } foreach ($matches[2] as $match) { $file = str_replace(array('$@FILEPHP@$', '$@SLASH@$', '$@FORCEDOWNLOAD@$'), array('', '/', ''), $match); - $files[] = rawurldecode($file); + if ($file === clean_param($file, PARAM_PATH)) { + $files[] = rawurldecode($file); + } } return array_unique($files); @@ -1210,6 +1212,10 @@ class moodle1_file_manager implements loggable { $sourcefullpath = $this->basepath.'/'.$sourcepath; + if ($sourcefullpath !== clean_param($sourcefullpath, PARAM_PATH)) { + throw new moodle1_convert_exception('file_invalid_path', $sourcefullpath); + } + if (!is_readable($sourcefullpath)) { throw new moodle1_convert_exception('file_not_readable', $sourcefullpath); }