Permalink
Browse files

MDL-36977 Be more picky when it comes to migrating files in moodle1 b…

…ackups
  • Loading branch information...
1 parent 4a27bde commit fd91456383bf1facffd9629f5af9d7835c339cce @mudrd8mz mudrd8mz committed with danpoltawski Jan 7, 2013
Showing with 8 additions and 1 deletion.
  1. +8 −1 backup/converter/moodle1/lib.php
@@ -640,7 +640,10 @@ public static function find_referenced_files($text) {
return $files;
}
foreach ($matches[2] as $match) {
- $files[] = str_replace(array('$@FILEPHP@$', '$@SLASH@$', '$@FORCEDOWNLOAD@$'), array('', '/', ''), $match);
+ $file = str_replace(array('$@FILEPHP@$', '$@SLASH@$', '$@FORCEDOWNLOAD@$'), array('', '/', ''), $match);
+ if ($file === clean_param($file, PARAM_PATH)) {
+ $files[] = rawurldecode($file);
+ }
}
return array_unique($files);
@@ -1205,6 +1208,10 @@ public function migrate_file($sourcepath, $filepath = '/', $filename = null, $so
$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);
}

0 comments on commit fd91456

Please sign in to comment.