Diff for /loncom/publisher/loncfile.pm between versions 1.58 and 1.64

version 1.58, 2004/07/02 08:07:17 version 1.64, 2004/12/28 21:28:49
Line 289  sub checksuffix { Line 289  sub checksuffix {
 }  }
   
 sub cleanDest {  sub cleanDest {
     my ($request,$dest,$subdir)=@_;      my ($request,$dest,$subdir,$fn,$uname)=@_;
     #remove bad characters      #remove bad characters
     my $foundbad=0;      my $foundbad=0;
     if ($subdir && $dest =~/\./) {      if ($subdir && $dest =~/\./) {
Line 298  sub cleanDest { Line 298  sub cleanDest {
     }      }
     if  ($dest=~/[\#\?&%\"]/) {      if  ($dest=~/[\#\?&%\"]/) {
  $foundbad=1;   $foundbad=1;
  $dest=~s/[\#\?&%]//g;   $dest=~s/[\#\?&%\"]//g;
       }
       if ($dest=~m|/|) {
    my ($newpath)=($dest=~m|(.*)/|);
    $newpath=&relativeDest($fn,$newpath,$uname);
    if (! -d "$newpath") {
       $request->print("<p><font color=\"red\">".&mt('You have requested to create file in directory [_1] which doesn\'t exist. The requested directory path has been removed from the requested file name.','"<tt>'.$newpath.'</tt>"')."</font></p>");
       $dest=~s|.*/||;
    }
     }      }
     if ($foundbad) {      if ($foundbad) {
  $request->print("<p><font color=\"red\">".&mt('Invalid characters in requested name have been removed.')."</font></p>");   $request->print("<p><font color=\"red\">".&mt('Invalid characters in requested name have been removed.')."</font></p>");
Line 760  sub phaseone { Line 768  sub phaseone {
       
     my $doingdir=0;      my $doingdir=0;
     if ($ENV{'form.action'} eq 'newdir') { $doingdir=1; }      if ($ENV{'form.action'} eq 'newdir') { $doingdir=1; }
     my $newfilename=&cleanDest($r,$ENV{'form.newfilename'},$doingdir);      my $newfilename=&cleanDest($r,$ENV{'form.newfilename'},$doingdir,$fn,$uname);
     $newfilename=&relativeDest($fn,$newfilename,$uname);      $newfilename=&relativeDest($fn,$newfilename,$uname);
     $r->print('<form action="/adm/cfile" method="post">'.      $r->print('<form action="/adm/cfile" method="post">'.
       '<input type="hidden" name="qualifiedfilename" value="'.$fn.'" />'.        '<input type="hidden" name="qualifiedfilename" value="'.$fn.'" />'.
Line 988  sub Copy2 { Line 996  sub Copy2 {
  unless (copy($oldfile, $newfile)) {   unless (copy($oldfile, $newfile)) {
     $request->print('<font color="red"> '.&mt('copy Error').': '.$!.'</font>');      $request->print('<font color="red"> '.&mt('copy Error').': '.$!.'</font>');
     return 0;      return 0;
    } elsif (!chmod(0660, $newfile)) {
       $request->print('<font color="red"> '.&mt('chmod error').': '.$!.'</font>');
       return 0;
    } elsif (-e $oldfile.'.meta' && 
    !copy($oldfile.'.meta', $newfile.'.meta') &&
    !chmod(0660, $newfile.'.meta')) {
       $request->print('<font color="red"> '.&mt('copy metadata error').
       ': '.$!.'</font>');
       return 0;
  } else {   } else {
     unless (chmod(0660, $newfile)) {  
  $request->print('<font color="red"> '.&mt('chmod error').': '.$!.'</font>');  
  return 0;  
     }  
     return 1;      return 1;
  }   }
     } else {      } else {
Line 1118  sub phasetwo { Line 1131  sub phasetwo {
     return ;      return ;
  }   }
  $dest = $dir."/.";   $dest = $dir."/.";
     } elsif ($ENV{'form.action'} eq 'rename') { # Rename.      } elsif ($ENV{'form.action'} eq 'rename' ||
        $ENV{'form.action'} eq 'move') {
  if($ENV{'form.newfilename'}) {   if($ENV{'form.newfilename'}) {
     if (!defined($dir)) {      if (!defined($dir)) {
  $fn=~m:^(.*)/:;   $fn=~m:^(.*)/:;
Line 1166  sub handler { Line 1180  sub handler {
   
     $r=shift;      $r=shift;
   
       &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['decompress','action','filename','newfilename']);
   
     &Debug($r, "loncfile.pm - handler entered");      &Debug($r, "loncfile.pm - handler entered");
     &Debug($r, " filename: ".$ENV{'form.filename'});      &Debug($r, " filename: ".$ENV{'form.filename'});
Line 1184  sub handler { Line 1199  sub handler {
     }  elsif($ENV{'QUERY_STRING'} && $ENV{'form.phase'} ne 'two') {        }  elsif($ENV{'QUERY_STRING'} && $ENV{'form.phase'} ne 'two') {  
  #Just hijack the script only the first time around to inject the   #Just hijack the script only the first time around to inject the
  #correct information for further processing   #correct information for further processing
  &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['decompress']);  
  $fn=&Apache::lonnet::unescape($ENV{'form.decompress'});   $fn=&Apache::lonnet::unescape($ENV{'form.decompress'});
  $fn=&URLToPath($fn);   $fn=&URLToPath($fn);
  $ENV{'form.action'}="decompress";   $ENV{'form.action'}="decompress";

Removed from v.1.58  
changed lines
  Added in v.1.64


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>