MDL-75237 qformat_blackboard_six: sanitise blackboard import file paths

This commit is contained in:
Petr Skoda 2022-07-15 19:12:28 +02:00 committed by Jenkins
parent 5ed64ce150
commit 2f70b320bb

View File

@ -65,7 +65,7 @@ class qformat_blackboard_six extends qformat_blackboard_six_base {
* @return mixed contents array or false on failure
*/
public function get_filecontent($path) {
$fullpath = $this->tempdir . '/' . $path;
$fullpath = $this->tempdir . '/' . clean_param($path, PARAM_PATH);
if (is_file($fullpath) && is_readable($fullpath)) {
return file_get_contents($fullpath);
}
@ -152,7 +152,7 @@ class qformat_blackboard_six extends qformat_blackboard_six_base {
}
if ($examfile->getAttribute('type') == 'assessment/x-bb-pool') {
if ($examfile->getAttribute('baseurl')) {
$fileobj->filebase = $this->tempdir. '/' . $examfile->getAttribute('baseurl');
$fileobj->filebase = $this->tempdir. '/' . clean_param($examfile->getAttribute('baseurl'), PARAM_PATH);
}
if ($content = $this->get_filecontent($examfile->getAttribute('file'))) {
$fileobj->filetype = self::FILETYPE_POOL;