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

www lon-capa-cvs@mail.lon-capa.org
Mon, 30 May 2005 16:56:48 -0000


www		Mon May 30 12:56:48 2005 EDT

  Modified files:              
    /loncom/publisher	loncfile.pm lonpublisher.pm 
  Log:
  Bug 3392 - don't allow ':::', etc
  Bug 4113 - require extensions
  
  
Index: loncom/publisher/loncfile.pm
diff -u loncom/publisher/loncfile.pm:1.68 loncom/publisher/loncfile.pm:1.69
--- loncom/publisher/loncfile.pm:1.68	Wed May 25 18:27:17 2005
+++ loncom/publisher/loncfile.pm	Mon May 30 12:56:46 2005
@@ -9,7 +9,7 @@
 #  and displays a page showing the results of the action.
 #
 #
-# $Id: loncfile.pm,v 1.68 2005/05/25 22:27:17 albertel Exp $
+# $Id: loncfile.pm,v 1.69 2005/05/30 16:56:46 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -710,7 +710,13 @@
         ##Informs User (name).(number).(extension) not allowed 
 	if($newfilename =~ /\.(\d+)\.(\w+)$/){
 	    $r->print('<font color="red">'.$newfilename.
-		      ' - '.&mt('Bad Filename').'<br />('.&mt('name').').('.&mt('number').').('.&mt('extension').')'.
+		      ' - '.&mt('Bad Filename').'<br />('.&mt('name').').('.&mt('number').').('.&mt('extension').') '.
+		      ' '.&mt('Not Allowed').'</font>');
+	    return;
+	}
+	if($newfilename =~ /(\:\:\:|\&\&\&|\_\_\_)/){
+	    $r->print('<font color="red">'.$newfilename.
+		      ' - '.&mt('Bad Filename').'<br />('.&mt('Must not include').' '.$1.') '.
 		      ' '.&mt('Not Allowed').'</font>');
 	    return;
 	}
Index: loncom/publisher/lonpublisher.pm
diff -u loncom/publisher/lonpublisher.pm:1.195 loncom/publisher/lonpublisher.pm:1.196
--- loncom/publisher/lonpublisher.pm:1.195	Fri May 20 14:28:22 2005
+++ loncom/publisher/lonpublisher.pm	Mon May 30 12:56:46 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Publication Handler
 #
-# $Id: lonpublisher.pm,v 1.195 2005/05/20 18:28:22 www Exp $
+# $Id: lonpublisher.pm,v 1.196 2005/05/30 16:56:46 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1398,13 +1398,29 @@
     my ($r,$source,$target,$style,$distarget,$batch)=@_;
     $source=~s/\/+/\//g;
     $target=~s/\/+/\//g;
-
-    if ($target=~/\_\_\_/) {
-	$r->print(
- '<font color="red">'.&mt('Unsupported character combination').
-		  ' "<tt>___</tt>" '.&mt('in filename, FAIL').'</font>');
-        return 0;
+#
+# Unless trying to get rid of something, check name validity
+#
+    unless ($env{'form.obsolete'}) {
+	if ($target=~/(\_\_\_|\&\&\&|\:\:\:)/) {
+	    $r->print(
+		      '<font color="red">'.&mt('Unsupported character combination').
+		      ' "<tt>'.$1.'</tt>" '.&mt('in filename, FAIL').'</font>');
+	    return 0;
+	}
+	unless ($target=~/\.(\w+)$/) {
+	    $r->print('<font color="red">'.&mt('No valid extension found in filename, FAIL').'</font>');
+	    return 0;
+	}
+	if ($target=~/\.(\d+)\.(\w+)$/) {
+	    $r->print('<font color="red">'.&mt('Cannot publish versioned resource, FAIL').'</font>');
+	    return 0;
+	}
     }
+
+#
+# End name check
+#
     $distarget=~s/\/+/\//g;
     my $logfile;
     unless ($logfile=Apache::File->new('>>'.$source.'.log')) {