MDL-81035 core: Fix redirect with sub-path

This commit is contained in:
Huong Nguyen
2024-03-11 15:56:06 +07:00
parent 38a3310c92
commit a7503b01ce
+7 -1
View File
@@ -958,7 +958,13 @@ function initialise_fullme() {
throw new moodle_exception('requirecorrectaccess', 'error', '', null,
'You called ' . $calledurl .', you should have called ' . $correcturl);
}
redirect($CFG->wwwroot . $rurl['fullpath'], get_string('wwwrootmismatch', 'error', $CFG->wwwroot), 3);
$rfullpath = $rurl['fullpath'];
// Check that URL is under $CFG->wwwroot.
if (strpos($rfullpath, $wwwroot['path']) === 0) {
$rfullpath = substr($rurl['fullpath'], strlen($wwwroot['path']) - 1);
$rfullpath = (new moodle_url($rfullpath))->out(false);
}
redirect($rfullpath, get_string('wwwrootmismatch', 'error', $CFG->wwwroot), 3);
}
}