From 370f2b7485a4d29f80f510e6db748707b55d82a9 Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Tue, 18 Mar 2025 17:12:30 -0500 Subject: [PATCH 1/2] Properly quote file names in the regexp used to extract backup times. If a backup filename contains certain special characters, then an exception is thrown when used in the regular expression to extract the time from the backup filename. To protect against this the metaquoting escape sequence (`\Q...\E`) is needed. This fixes issue #2680. --- lib/WeBWorK/ContentGenerator/Instructor/PGProblemEditor.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/WeBWorK/ContentGenerator/Instructor/PGProblemEditor.pm b/lib/WeBWorK/ContentGenerator/Instructor/PGProblemEditor.pm index 6d207da945..504137b020 100644 --- a/lib/WeBWorK/ContentGenerator/Instructor/PGProblemEditor.pm +++ b/lib/WeBWorK/ContentGenerator/Instructor/PGProblemEditor.pm @@ -620,7 +620,7 @@ sub getBackupTimes ($c) { my $backupBasePath = $c->{backupBasePath}; my @files = glob(qq("$backupBasePath*")); return unless @files; - return reverse(map { $_ =~ s/$backupBasePath//r } @files); + return reverse(map { $_ =~ s/\Q$backupBasePath\E//r } @files); } sub backupFile ($c, $outputFilePath) { From a80be4149080e6ee8a938645f4b204160bbd2d5b Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Tue, 18 Mar 2025 17:24:25 -0500 Subject: [PATCH 2/2] Do not consider parentheses to be illegal characters in file names in the File Manager. This prevents deletion of files that have parentheses in the name. --- lib/WeBWorK/ContentGenerator/Instructor/FileManager.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/WeBWorK/ContentGenerator/Instructor/FileManager.pm b/lib/WeBWorK/ContentGenerator/Instructor/FileManager.pm index 350e1f7211..61e48458d6 100644 --- a/lib/WeBWorK/ContentGenerator/Instructor/FileManager.pm +++ b/lib/WeBWorK/ContentGenerator/Instructor/FileManager.pm @@ -988,7 +988,7 @@ sub checkPWD ($c, $pwd, $renameError = 0) { my $original = $pwd; $pwd =~ s!(^|/)\.!$1_!g; # don't enter hidden directories $pwd =~ s!^/!!; # remove leading / - $pwd =~ s![^-_./A-Z0-9~, ]!_!gi; # no illegal characters + $pwd =~ s![^-_./A-Z0-9~,() ]!_!gi; # no illegal characters return if $renameError && $original ne $pwd; $pwd = '.' if $pwd eq '';