Merge branch 'MDL-39505-migrate-file-backport_24' of git://github.com/mudrd8mz/moodle into MOODLE_24_STABLE

This commit is contained in:
Sam Hemelryk 2013-06-11 17:16:15 +12:00
commit 2a31efea1b

View file

@ -1210,12 +1210,16 @@ class moodle1_file_manager implements loggable {
*/
public function migrate_file($sourcepath, $filepath = '/', $filename = null, $sortorder = 0, $timecreated = null, $timemodified = null) {
$sourcefullpath = $this->basepath.'/'.$sourcepath;
// Normalise Windows paths a bit.
$sourcepath = str_replace('\\', '/', $sourcepath);
if ($sourcefullpath !== clean_param($sourcefullpath, PARAM_PATH)) {
throw new moodle1_convert_exception('file_invalid_path', $sourcefullpath);
// PARAM_PATH must not be used on full OS path!
if ($sourcepath !== clean_param($sourcepath, PARAM_PATH)) {
throw new moodle1_convert_exception('file_invalid_path', $sourcepath);
}
$sourcefullpath = $this->basepath.'/'.$sourcepath;
if (!is_readable($sourcefullpath)) {
throw new moodle1_convert_exception('file_not_readable', $sourcefullpath);
}