MDL-81267 mod_data: Clean field type before inclusion
* Filter out wrong field types when restoring or creating a field.
This commit is contained in:
@@ -1051,6 +1051,7 @@ function data_get_field_from_id($fieldid, $data){
|
||||
function data_get_field_new($type, $data) {
|
||||
global $CFG;
|
||||
|
||||
$type = clean_param($type, PARAM_ALPHA);
|
||||
$filepath = $CFG->dirroot.'/mod/data/field/'.$type.'/field.class.php';
|
||||
// It should never access this method if the subfield class doesn't exist.
|
||||
if (!file_exists($filepath)) {
|
||||
@@ -1078,6 +1079,7 @@ function data_get_field(stdClass $field, stdClass $data, ?stdClass $cm=null): da
|
||||
if (!isset($field->type)) {
|
||||
return new data_field_base($field);
|
||||
}
|
||||
$field->type = clean_param($field->type, PARAM_ALPHA);
|
||||
$filepath = $CFG->dirroot.'/mod/data/field/'.$field->type.'/field.class.php';
|
||||
if (!file_exists($filepath)) {
|
||||
return new data_field_base($field);
|
||||
|
||||
Reference in New Issue
Block a user