--- loncom/publisher/loncfile.pm 2003/08/04 20:34:19 1.39
+++ loncom/publisher/loncfile.pm 2003/11/19 15:06:33 1.45
@@ -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.45 2003/11/19 15:06:33 taceyjo1 Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -110,7 +110,7 @@ sub Debug {
# Put out the indicated message butonly if DEBUG is true.
if ($DEBUG) {
- $log->debug($message);
+ $log->debug($message);
}
}
@@ -168,7 +168,7 @@ sub url {
sub display {
my $fn=shift;
- $fn=~s/^\/home\/(\w+)\/public\_html//;
+ $fn=~s-^/home/(\w+)/public_html-/priv/$1-;
return ''.$fn.'';
}
@@ -387,6 +387,10 @@ sub Rename1 {
if(-e $fn) {
if($newfilename) {
+ # is dest a dir
+ if (-d $newfilename) {
+ if ($fn =~ m|/([^/]*)$|) { $newfilename .= '/'.$1; }
+ }
if ($newfilename =~ m|/[^\.]+$|) {
#no extension add on original extension
if ($fn =~ m|/[^\.]*\.([^\.]+)$|) {
@@ -399,6 +403,10 @@ sub Rename1 {
if (-d $fn) {
$newfilename=~s/\/[^\/]+\/([^\/]+)$/\/$1/;
}
+ $newfilename=~s://+:/:g; # remove duplicate /
+ while ($newfilename=~m:/\.\./:) {
+ $newfilename=~ s:/[^/]+/\.\./:/:g; #remove dir/..
+ }
my $return=&exists($user, $domain, $newfilename);
$request->print($return);
if ($return =~/^Error:/) {
@@ -485,24 +493,36 @@ Parameters:
=cut
sub Copy1 {
- my ($request, $user, $domain, $fn, $newfilename) = @_;
+ my ($request, $user, $domain, $fn, $newfilename) = @_;
- if(-e $fn) {
- $request->print(&checksuffix($fn,$newfilename));
- my $return=&exists($user, $domain, $newfilename);
- $request->print($return);
- if ($return =~/^Error:/) {
- $request->print('
Cancel');
- return;
+ if(-e $fn) {
+ # is dest a dir
+ if (-d $newfilename) {
+ if ($fn =~ m|/([^/]*)$|) { $newfilename .= '/'.$1; }
+ }
+ if ($newfilename =~ m|/[^\.]+$|) {
+ #no extension add on original extension
+ if ($fn =~ m|/[^\.]*\.([^\.]+)$|) { $newfilename.='.'.$1; }
+ }
+ $newfilename=~s://+:/:g; # remove duplicate /
+ while ($newfilename=~m:/\.\./:) {
+ $newfilename=~ s:/[^/]+/\.\./:/:g; #remove dir/..
+ }
+ $request->print(&checksuffix($fn,$newfilename));
+ my $return=&exists($user, $domain, $newfilename);
+ $request->print($return);
+ if ($return =~/^Error:/) {
+ $request->print('
Cancel');
+ return;
+ }
+ $request->print('
Copy '.&display($fn).'
to '.
+ &display($newfilename).'?
No such file: '.&display($fn).'
'); } - $request->print('Copy '.&display($fn).'
to '.
- &display($newfilename).'?
No such file: '.&display($fn).'
'); - } } =pod @@ -559,6 +579,17 @@ sub NewDir1 } } + +sub Decompress1 { + my ($request, $user, $domain, $fn) = @_; + if( -e $fn) { + $request->print(''); + $request->print('Decompress '.&display($fn).'?
'); + &CloseForm1($request, $fn); + } else { + $request->print('No such file: '.&display($fn).'
'); + } +} =pod =item NewFile1 @@ -605,6 +636,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