--- loncom/publisher/loncfile.pm 2003/08/04 20:34:19 1.39
+++ loncom/publisher/loncfile.pm 2003/08/28 20:28:33 1.41
@@ -9,7 +9,7 @@
# and displays a page showing the results of the action.
#
#
-# $Id: loncfile.pm,v 1.39 2003/08/04 20:34:19 www Exp $
+# $Id: loncfile.pm,v 1.41 2003/08/28 20:28:33 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -605,6 +605,14 @@ sub NewFile1 {
if ($ENV{'form.action'} =~ /new(.+)file/) {
my $extension=$1;
+
+ ##Informs User (name).(number).(extension) not allowed
+ if($newfilename =~ /\.(\d+)\.(\w+)$/){
+ $r->print(''.$newfilename.
+ ' - Bad Filename
(name).(number).(extension)'.
+ ' Not Allowed');
+ return;
+ }
if ($newfilename !~ /\Q.$extension\E$/) {
if ($newfilename =~ m|^[^\.]*\.([^\.]+)$|) {
#already has an extension strip it and add in expected one
@@ -736,10 +744,44 @@ sub Rename2 {
&Debug($request, "Target is: ".$directory.'/'.
$newfile);
if (-e $oldfile) {
+
+ my $oRN=$oldfile;
+ my $nRN=$newfile;
unless (rename($oldfile,$newfile)) {
$request->print('Error: '.$!.'');
return 0;
}
+ ## If old name.(extension) exits, move under new name.
+ ## If it doesn't exist and a new.(extension) exists
+ ## delete it (only concern when renaming over files)
+ my $tmp1=$oRN.'.meta';
+ my $tmp2=$nRN.'.meta';
+ if(-e $tmp1){
+ unless(rename($tmp1,$tmp2)){ }
+ } elsif(-e $tmp2){
+ unlink $tmp2;
+ }
+ $tmp1=$oRN.'.save';
+ $tmp2=$nRN.'.save';
+ if(-e $tmp1){
+ unless(rename($tmp1,$tmp2)){ }
+ } elsif(-e $tmp2){
+ unlink $tmp2;
+ }
+ $tmp1=$oRN.'.log';
+ $tmp2=$nRN.'.log';
+ if(-e $tmp1){
+ unless(rename($tmp1,$tmp2)){ }
+ } elsif(-e $tmp2){
+ unlink $tmp2;
+ }
+ $tmp1=$oRN.'.bak';
+ $tmp2=$nRN.'.bak';
+ if(-e $tmp1){
+ unless(rename($tmp1,$tmp2)){ }
+ } elsif(-e $tmp2){
+ unlink $tmp2;
+ }
} else {
$request->print("
No such file: ".&display($oldfile).'
'); return 0;