--- loncom/publisher/loncfile.pm 2003/06/19 20:49:13 1.31 +++ loncom/publisher/loncfile.pm 2003/08/01 20:32:05 1.35 @@ -9,7 +9,7 @@ # and displays a page showing the results of the action. # # -# $Id: loncfile.pm,v 1.31 2003/06/19 20:49:13 albertel Exp $ +# $Id: loncfile.pm,v 1.35 2003/08/01 20:32:05 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -92,6 +92,7 @@ use Apache::Constants qw(:common :http : use Apache::loncacc; use Apache::Log (); use Apache::lonnet; +use Apache::loncommon(); my $DEBUG=0; my $r; # Needs to be global for some stuff RF. @@ -172,8 +173,9 @@ Global References sub URLToPath { my $Url = shift; &Debug($r, "UrlToPath got: $Url"); - $Url=~ s/^http\:\/\/[^\/]+\/\~(\w+)/\/home\/$1\/public_html/; $Url=~ s/^http\:\/\/[^\/]+//; + $Url=~ s/^\///; + $Url=~ s/(\~|priv\/)(\w+)\//\/home\/$2\/public_html\//; &Debug($r, "Returning $Url \n"); return $Url; } @@ -387,6 +389,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) @@ -778,12 +791,6 @@ sub NewFile1 { } } - #remove bad characters - if ($newfilename=~/[\#\?&]/) { - $request->print("

Invalid characters in requested filename have been removed.

"); - $newfilename=~s/[\#\?&]//g; - } - my $fullpath = $dir.'/'.$newfilename; &Debug($request, "Full path is : ".$fullpath); @@ -842,7 +849,8 @@ sub phaseone { # my $conspace=ConstructionPathFromRelative($uname, $fn); - + $ENV{'form.newfilename'}=&cleanDest($r,$ENV{'form.newfilename'}); + $r->print('
'. ''. ''. @@ -872,6 +880,8 @@ sub phaseone { $ENV{'form.action'} eq 'newproblemfile' || $ENV{'form.action'} eq 'newpagefile' || $ENV{'form.action'} eq 'newsequencefile' || + $ENV{'form.action'} eq 'newrightsfile' || + $ENV{'form.action'} eq 'newstyfile' || $ENV{'form.action'} eq 'Select Action') { if($ENV{'form.newfilename'}) { my $newfilename = $ENV{'form.newfilename'}; @@ -1232,12 +1242,7 @@ sub handler { if ($ENV{'form.filename'}) { $fn=&Apache::lonnet::unescape($ENV{'form.filename'}); - &Debug($r, "loncfile::handler - raw url: $fn"); -# $fn=~s/^http\:\/\/[^\/]+\/\~(\w+)/\/home\/$1\/public_html/; -# $fn=~s/^http\:\/\/[^\/]+//; - $fn=URLToPath($fn); - &Debug($r, "loncfile::handler - doctored url: $fn"); - + $fn=&URLToPath($fn); } else { &Debug($r, "loncfile::handler - no form.filename"); $r->log_reason($ENV{'user.name'}.' at '.$ENV{'user.domain'}. @@ -1276,8 +1281,7 @@ sub handler { $r->print('LON-CAPA Construction Space'); - $r->print( - ''); + $r->print(&Apache::loncommon::bodytag('File Operation')); $r->print('

Construction Space '.$fn.'

'); @@ -1303,6 +1307,8 @@ sub handler { $ENV{'form.action'} eq 'newproblemfile' || $ENV{'form.action'} eq 'newpagefile' || $ENV{'form.action'} eq 'newsequencefile' || + $ENV{'form.action'} eq 'newrightsfile' || + $ENV{'form.action'} eq 'newstyfile' || $ENV{'form.action'} eq 'Select Action' ) { $r->print('

New Resource

'); } else {