MDL-33886 backup: Add backup filename length < 255 char validation

This commit is contained in:
Zig Tan
2017-12-22 13:03:08 +08:00
parent 9993c1d02c
commit 85ba9528c9
2 changed files with 3 additions and 0 deletions
@@ -122,6 +122,8 @@ class backup_confirmation_form extends backup_moodleform {
if (!array_key_exists('setting_root_filename', $errors)) {
if (trim($data['setting_root_filename']) == '') {
$errors['setting_root_filename'] = get_string('errorfilenamerequired', 'backup');
} else if (strlen(trim($data['setting_root_filename'])) > 255) {
$errors['setting_root_filename'] = get_string('errorfilenametoolong', 'backup');
} else if (!preg_match('#\.mbz$#i', $data['setting_root_filename'])) {
$errors['setting_root_filename'] = get_string('errorfilenamemustbezip', 'backup');
}
+1
View File
@@ -140,6 +140,7 @@ $string['error_block_for_module_not_found'] = 'Orphan block instance (id: {$a->b
$string['error_course_module_not_found'] = 'Orphan course module (id: {$a}) found. This module will not be backed up.';
$string['errorcopyingbackupfile'] = "Failed to copy the backup file to the temporary folder before restoring.";
$string['errorfilenamerequired'] = 'You must enter a valid filename for this backup';
$string['errorfilenametoolong'] = 'The filename length you enter must be less than 255 characters';
$string['errorfilenamemustbezip'] = 'The filename you enter must be a ZIP file and have the .mbz extension';
$string['errorminbackup20version'] = 'This backup file has been created with one development version of Moodle backup ({$a->backup}). Minimum required is {$a->min}. Cannot be restored.';
$string['errorinvalidformat'] = 'Unknown backup format';