--- loncom/publisher/loncfile.pm 2002/09/10 02:31:26 1.18 +++ loncom/publisher/loncfile.pm 2002/10/28 23:23:41 1.19 @@ -10,7 +10,7 @@ # # -# $Id: loncfile.pm,v 1.18 2002/09/10 02:31:26 foxr Exp $ +# $Id: loncfile.pm,v 1.19 2002/10/28 23:23:41 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -493,10 +493,11 @@ sub Rename1 { my $newfilename = $ENV{'form.newfilename'}; $request->print(&checksuffix($filename, $newfilename)); $request->print(&exists($user, $domain, $dir, $newfilename)); + my $dest=&SimplifyDir($dir,$newfilename); $request->print('
Rename '.$filename.' to '. - $dir.'/'.$newfilename.'?
'); + '">Rename '.$filename.'
to '.
+ $dest.'?
No new filename specified
'); @@ -587,14 +588,14 @@ sub Copy1 { $cancelurl =~ s/\/public_html//; - if(-e $filename) { $request->print(&checksuffix($filename,$newfilename)); $request->print(&exists($user, $domain, $dir, $newfilename)); + my $dest=&SimplifyDir($dir,$newfilename); $request->print('Copy '.$filename.' to'. - ''.$dir.'/'.$newfilename.'/?
'); + '">Copy '.$filename.'
to '.
+ ''.$dest.'?
No such file '.$filename.'
'); @@ -602,6 +603,34 @@ sub Copy1 { } =pod + +=item SimplifyDir + + Removes all extra / and all .. references + +Parameters: + +=over 4 + +=item $dir - string [in] a directory name + +=item $file - string [in] a file reference relative to $dir + +=back + +Results: the concatenated path. + +=cut + +sub SimplifyDir { + my ($dir,$file) = @_; + my $location = $dir. '/'.$file; + $location=~s://+:/:g; # remove duplicate / + while ($location=~m:/\.\./:) {$location=~s:/[^/]+/\.\./:/:g;}#remove dir/.. + return $location; +} + +=pod =item NewDir1