Skip to content

Commit

Permalink
MDL-33886 backup: Add backup filename length < 255 char validation
Browse files Browse the repository at this point in the history
  • Loading branch information
zig-moodle committed Dec 22, 2017
1 parent 16deaa8 commit e714f3c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions backup/util/ui/backup_moodleform.class.php
Expand Up @@ -122,6 +122,8 @@ public function validation($data, $files) {
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');
}
Expand Down
1 change: 1 addition & 0 deletions lang/en/backup.php
Expand Up @@ -140,6 +140,7 @@
$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';
Expand Down

0 comments on commit e714f3c

Please sign in to comment.