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

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 19 Jun 2003 21:04:37 -0000


albertel		Thu Jun 19 17:04:37 2003 EDT

  Modified files:              
    /loncom/publisher	loncfile.pm 
  Log:
  - better solution to BUG#1242, cleans onall actions now
  
  
  
Index: loncom/publisher/loncfile.pm
diff -u loncom/publisher/loncfile.pm:1.31 loncom/publisher/loncfile.pm:1.32
--- loncom/publisher/loncfile.pm:1.31	Thu Jun 19 16:49:13 2003
+++ loncom/publisher/loncfile.pm	Thu Jun 19 17:04:37 2003
@@ -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.32 2003/06/19 21:04:37 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -387,6 +387,17 @@
     }
     return $result;
 }
+
+sub cleanDest {
+    my ($request,$dest)=@_;
+    #remove bad characters
+    if  ($dest=~/[\#\?&]/) {
+	$request->print("<p><font color=\"red\">Invalid characters in requested name have been removed.</font></p>");
+	$dest=~s/[\#\?&]//g;
+    }
+    return $dest;
+}
+
 =pod
 
 =item CloseForm1($request, $user, $file)
@@ -778,12 +789,6 @@
 	}
     }
 
-    #remove bad characters
-    if  ($newfilename=~/[\#\?&]/) {
-	$request->print("<p><font color=\"red\">Invalid characters in requested filename have been removed.</font></p>");
-	$newfilename=~s/[\#\?&]//g;
-    }
-
     my $fullpath = $dir.'/'.$newfilename;
 
     &Debug($request, "Full path is : ".$fullpath);
@@ -842,7 +847,8 @@
   
   #  my $conspace=ConstructionPathFromRelative($uname, $fn);
   
-  
+  $ENV{'form.newfilename'}=&cleanDest($r,$ENV{'form.newfilename'});
+
   $r->print('<form action="/adm/cfile" method="post">'.
 	    '<input type="hidden" name="filename" value="/~'.$uname.$fn.'" />'.
 	    '<input type="hidden" name="phase" value="two" />'.