MDL-76810 redirect handling: ensure return URLs are properly sanitised

This commit is contained in:
Tim Hunt 2023-01-06 12:55:40 +00:00 committed by Jake Dallimore
parent 6f1c9d3b53
commit 3b23ff6fec
7 changed files with 8 additions and 8 deletions

View File

@ -48,7 +48,7 @@ class backup_files_edit_form extends moodleform {
$mform->setType('component', PARAM_COMPONENT);
$mform->addElement('hidden', 'returnurl', $this->_customdata['returnurl']);
$mform->setType('returnurl', PARAM_URL);
$mform->setType('returnurl', PARAM_LOCALURL);
$this->add_action_buttons(true, get_string('savechanges'));
$this->set_data($this->_customdata['data']);

View File

@ -64,7 +64,7 @@ class blog_edit_external_form extends moodleform {
$mform->setDefault('id', 0);
$mform->addElement('hidden', 'returnurl');
$mform->setType('returnurl', PARAM_URL);
$mform->setType('returnurl', PARAM_LOCALURL);
$mform->setDefault('returnurl', 0);
}

View File

@ -34,7 +34,7 @@ require_once($CFG->dirroot.'/course/lib.php');
$id = required_param('id', PARAM_INT);
$switchrole = optional_param('switchrole', -1, PARAM_INT);
$returnurl = optional_param('returnurl', '', PARAM_RAW);
$returnurl = optional_param('returnurl', '', PARAM_LOCALURL);
if (strpos($returnurl, '?') === false) {
// Looks like somebody did not set proper page url, better go to course page.
@ -43,7 +43,7 @@ if (strpos($returnurl, '?') === false) {
if (strpos($returnurl, $CFG->wwwroot) !== 0) {
$returnurl = $CFG->wwwroot.$returnurl;
}
$returnurl = clean_param($returnurl, PARAM_URL);
$returnurl = clean_param($returnurl, PARAM_LOCALURL);
}
$PAGE->set_url('/course/switchrole.php', array('id'=>$id, 'switchrole'=>$switchrole));

View File

@ -36,7 +36,7 @@ class mod_wiki_filesedit_form extends moodleform {
$mform->addElement('filemanager', 'files_filemanager', get_string('files'), null, $options);
$mform->addElement('hidden', 'returnurl', $data->returnurl);
$mform->setType('returnurl', PARAM_URL);
$mform->setType('returnurl', PARAM_LOCALURL);
$mform->addElement('hidden', 'subwiki', $data->subwikiid);
$mform->setType('subwiki', PARAM_INT);

View File

@ -30,7 +30,7 @@ require_login();
core_question\local\bank\helper::require_plugin_enabled('qbank_history');
$entryid = required_param('entryid', PARAM_INT);
$returnurl = required_param('returnurl', PARAM_RAW);
$returnurl = required_param('returnurl', PARAM_LOCALURL);
list($thispageurl, $contexts, $cmid, $cm, $module, $pagevars) =
question_edit_setup('questions', '/question/bank/history/history.php');

View File

@ -48,7 +48,7 @@ define('QUESTION_PREVIEW_MAX_VARIANTS', 100);
// Get and validate question id.
$id = required_param('id', PARAM_INT);
$returnurl = optional_param('returnurl', null, PARAM_RAW);
$returnurl = optional_param('returnurl', null, PARAM_LOCALURL);
$question = question_bank::load_question($id);

View File

@ -61,7 +61,7 @@ if ($formaction == 'bulkchange.php') {
$userids = optional_param_array('userid', array(), PARAM_INT);
$default = new moodle_url('/user/index.php', ['id' => $course->id]);
$returnurl = new moodle_url(optional_param('returnto', $default, PARAM_URL));
$returnurl = new moodle_url(optional_param('returnto', $default, PARAM_LOCALURL));
if (empty($userids)) {
$userids = optional_param_array('bulkuser', array(), PARAM_INT);