[LON-CAPA-cvs] cvs: loncom /publisher loncfile.pm

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 02 Jul 2004 08:07:17 -0000


albertel		Fri Jul  2 04:07:17 2004 EDT

  Modified files:              
    /loncom/publisher	loncfile.pm 
  Log:
  - BUG#3151, directories with . in their names cause all kinds of havoc.
  
  
Index: loncom/publisher/loncfile.pm
diff -u loncom/publisher/loncfile.pm:1.57 loncom/publisher/loncfile.pm:1.58
--- loncom/publisher/loncfile.pm:1.57	Thu Jun 10 14:20:16 2004
+++ loncom/publisher/loncfile.pm	Fri Jul  2 04:07:17 2004
@@ -9,7 +9,7 @@
 #  and displays a page showing the results of the action.
 #
 #
-# $Id: loncfile.pm,v 1.57 2004/06/10 18:20:16 albertel Exp $
+# $Id: loncfile.pm,v 1.58 2004/07/02 08:07:17 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -289,12 +289,20 @@
 }
 
 sub cleanDest {
-    my ($request,$dest)=@_;
+    my ($request,$dest,$subdir)=@_;
     #remove bad characters
+    my $foundbad=0;
+    if ($subdir && $dest =~/\./) {
+	$foundbad=1;
+	$dest=~s/\.//g;
+    }
     if  ($dest=~/[\#\?&%\"]/) {
-	$request->print("<p><font color=\"red\">".&mt('Invalid characters in requested name have been removed.')."</font></p>");
+	$foundbad=1;
 	$dest=~s/[\#\?&%]//g;
     }
+    if ($foundbad) {
+	$request->print("<p><font color=\"red\">".&mt('Invalid characters in requested name have been removed.')."</font></p>");
+    }
     return $dest;
 }
 
@@ -750,7 +758,9 @@
 sub phaseone {
     my ($r,$fn,$uname,$udom)=@_;
   
-    my $newfilename=&cleanDest($r,$ENV{'form.newfilename'});
+    my $doingdir=0;
+    if ($ENV{'form.action'} eq 'newdir') { $doingdir=1; }
+    my $newfilename=&cleanDest($r,$ENV{'form.newfilename'},$doingdir);
     $newfilename=&relativeDest($fn,$newfilename,$uname);
     $r->print('<form action="/adm/cfile" method="post">'.
 	      '<input type="hidden" name="qualifiedfilename" value="'.$fn.'" />'.