mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
MDL-14589: strrpos is needed to check the last occurence
MDL-15405: return the existing file in case one is found
This commit is contained in:
parent
95a5e161de
commit
00c32c5430
@ -394,7 +394,7 @@ class file_storage {
|
||||
|
||||
if ($key == 'filepath') {
|
||||
$value = clean_param($value, PARAM_PATH);
|
||||
if (strpos($value, '/') !== 0 or strpos($value, '/') !== strlen($value)-1) {
|
||||
if (strpos($value, '/') !== 0 or strrpos($value, '/') !== strlen($value)-1) {
|
||||
// path must start and end with '/'
|
||||
throw new file_exception('storedfileproblem', 'Invalid file path');
|
||||
}
|
||||
@ -621,6 +621,7 @@ class file_storage {
|
||||
if ($overwrite) {
|
||||
$oldfile->delete();
|
||||
} else {
|
||||
$returnfiles[] = $oldfile;
|
||||
continue; // Can't overwrite the existing file so skip it
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user