MDL-66024 tool_uploadcourse: validate shortname/fullname field length.
This commit is contained in:
@@ -412,6 +412,12 @@ class tool_uploadcourse_course {
|
||||
$this->error('invalidshortname', new lang_string('invalidshortname', 'tool_uploadcourse'));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Ensure we don't overflow the maximum length of the shortname field.
|
||||
if (core_text::strlen($this->shortname) > 255) {
|
||||
$this->error('invalidshortnametoolong', new lang_string('invalidshortnametoolong', 'tool_uploadcourse', 255));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$exists = $this->exists();
|
||||
@@ -479,6 +485,12 @@ class tool_uploadcourse_course {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Ensure we don't overflow the maximum length of the fullname field.
|
||||
if (!empty($coursedata['fullname']) && core_text::strlen($coursedata['fullname']) > 254) {
|
||||
$this->error('invalidfullnametoolong', new lang_string('invalidfullnametoolong', 'tool_uploadcourse', 254));
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the course does not exist, or will be forced created.
|
||||
if (!$exists || $mode === tool_uploadcourse_processor::MODE_CREATE_ALL) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user