Skip to content

Commit

Permalink
MDL-76810 redirect handling: ensure return URLs are properly sanitised
Browse files Browse the repository at this point in the history
  • Loading branch information
timhunt authored and snake committed Jan 11, 2023
1 parent 978a6bb commit 799f7fb
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion backup/backupfilesedit_form.php
Expand Up @@ -48,7 +48,7 @@ public function definition() {
$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']);
Expand Down
2 changes: 1 addition & 1 deletion blog/external_blog_edit_form.php
Expand Up @@ -64,7 +64,7 @@ public function definition() {
$mform->setDefault('id', 0);

$mform->addElement('hidden', 'returnurl');
$mform->setType('returnurl', PARAM_URL);
$mform->setType('returnurl', PARAM_LOCALURL);
$mform->setDefault('returnurl', 0);
}

Expand Down
4 changes: 2 additions & 2 deletions course/switchrole.php
Expand Up @@ -34,7 +34,7 @@

$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.
Expand All @@ -43,7 +43,7 @@
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));
Expand Down
2 changes: 1 addition & 1 deletion mod/wiki/filesedit_form.php
Expand Up @@ -36,7 +36,7 @@ protected function definition() {
$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);
Expand Down
2 changes: 1 addition & 1 deletion question/bank/history/history.php
Expand Up @@ -30,7 +30,7 @@
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');
Expand Down
2 changes: 1 addition & 1 deletion question/bank/previewquestion/preview.php
Expand Up @@ -48,7 +48,7 @@

// 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);

Expand Down
2 changes: 1 addition & 1 deletion user/action_redir.php
Expand Up @@ -61,7 +61,7 @@

$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);
Expand Down

0 comments on commit 799f7fb

Please sign in to comment.