--- loncom/publisher/loncfile.pm 2003/02/10 23:26:15 1.26 +++ loncom/publisher/loncfile.pm 2003/06/19 21:04:37 1.32 @@ -9,7 +9,7 @@ # and displays a page showing the results of the action. # # -# $Id: loncfile.pm,v 1.26 2003/02/10 23:26:15 albertel Exp $ +# $Id: loncfile.pm,v 1.32 2003/06/19 21:04:37 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -387,6 +387,17 @@ sub checksuffix { } return $result; } + +sub cleanDest { + my ($request,$dest)=@_; + #remove bad characters + if ($dest=~/[\#\?&]/) { + $request->print("
Invalid characters in requested name have been removed.
"); + $dest=~s/[\#\?&]//g; + } + return $dest; +} + =pod =item CloseForm1($request, $user, $file) @@ -412,7 +423,7 @@ sub CloseForm1 { &Debug($request, "Cancel url is: ".$cancelurl); $request->print(''); $request->print(''); + '" method="POST">'); } @@ -494,13 +505,19 @@ sub Rename1 { if(-e $conspace) { if($ENV{'form.newfilename'}) { my $newfilename = $ENV{'form.newfilename'}; - if ($newfilename =~ m|^[^\.]+$|) { + if ($newfilename =~ m|/[^\.]+$|) { #no extension add on orignal extension if ($filename =~ m|/[^\.]*\.([^\.]+)$|) { $newfilename.='.'.$1; } } $request->print(&checksuffix($filename, $newfilename)); + #renaming a dir, delete the trailing / + #remove last element for current dir + if ($filename =~ m|/$|) { + $filename =~ s|/$||; + $dir =~ s|/[^/]*$||; + } my $return=&exists($user, $domain, $dir, $newfilename); $request->print($return); if ($return =~/^Error:/) { @@ -786,9 +803,9 @@ sub NewFile1 { &Debug($request, "Dest url is: ".$dest); $request->print(''); $request->print(''); + '" method="POST">'); $request->print(''); + '" method="POST">'); } } @@ -830,16 +847,19 @@ sub phaseone { # my $conspace=ConstructionPathFromRelative($uname, $fn); - + $ENV{'form.newfilename'}=&cleanDest($r,$ENV{'form.newfilename'}); + $r->print('