[LON-CAPA-cvs] cvs: loncom /interface londocs.pm

albertel lon-capa-cvs@mail.lon-capa.org
Sat, 08 Jan 2005 06:42:15 -0000


albertel		Sat Jan  8 01:42:15 2005 EDT

  Modified files:              
    /loncom/interface	londocs.pm 
  Log:
  - was more robust than I orginally noticed, BUG#3807
  
  
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.163 loncom/interface/londocs.pm:1.164
--- loncom/interface/londocs.pm:1.163	Sat Jan  8 01:34:30 2005
+++ loncom/interface/londocs.pm	Sat Jan  8 01:42:15 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.163 2005/01/08 06:34:30 albertel Exp $
+# $Id: londocs.pm,v 1.164 2005/01/08 06:42:15 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -132,6 +132,11 @@
     }
 }
 
+sub clean {
+    my ($title)=@_;
+    $title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs;
+    return $title;	
+}
 # -------------------------------------------------------- Actually dump course
 
 sub dumpcourse {
@@ -149,7 +154,7 @@
 	my ($ca,$cd)=split(/\@/,$ENV{'form.authorspace'});
 	$r->print('<h3>'.&mt('Copying Files').'</h3>');
 	my $title=$ENV{'form.authorfolder'};
-	$title=~s/[^\w\/]+/\_/g;
+	$title=&clean($title);
 	my %replacehash=();
 	foreach (keys %ENV) {
 	    if ($_=~/^form\.namefor\_(.+)/) {
@@ -160,7 +165,7 @@
 	$crs=~s/\_/\//g;
 	foreach (keys %replacehash) {
 	    my $newfilename=$title.'/'.$replacehash{$_};
-	    $newfilename=~s/[^\w\/\.\/]+/\_/g;
+	    $newfilename=&clean($newfilename);
 	    my @dirs=split(/\//,$newfilename);
 	    my $path='/home/'.$ca.'/public_html';
 	    my $makepath=$path;
@@ -214,7 +219,7 @@
 	}
 	my $title=$origcrsdata{'description'};
 	$title=~s/\s+/\_/gs;
-	$title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs;
+	$title=&clean($title);
 	$r->print('<h3>'.&mt('Folder in Construction Space').'</h3><input type="text" size="50" name="authorfolder" value="'.$title.'" /><br />');
 	&tiehash();
 	$r->print('<h3>'.&mt('Filenames in Construction Space').'</h3><table border="2"><tr><th>'.&mt('Internal Filename').'</th><th>'.&mt('Title').'</th><th>'.&mt('Save as ...').'</th></tr>');
@@ -229,7 +234,7 @@
 		$title=$_;
 	    }
 	    $title=~s/\.(\w+)$//;
-	    $title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs;
+	    $title=&clean($title);
 	    $title.='.'.$ext;
 	    $r->print("\n<td><input type='text' size='60' name='namefor_".$_."' value='".$title."' /></td></tr>\n");
 	}