--- loncom/publisher/loncfile.pm 2009/04/04 21:45:57 1.95 +++ loncom/publisher/loncfile.pm 2009/05/11 16:51:32 1.97 @@ -9,7 +9,7 @@ # and displays a page showing the results of the action. # # -# $Id: loncfile.pm,v 1.95 2009/04/04 21:45:57 bisitz Exp $ +# $Id: loncfile.pm,v 1.97 2009/05/11 16:51:32 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -423,7 +423,7 @@ sub CloseForm1 { my ($request, $fn) = @_; $request->print('
'); $request->print(''); + '" method="post">'); } @@ -783,23 +783,10 @@ button which returns you to the driector sub NewFile1 { my ($request, $user, $domain, $fn, $newfilename) = @_; + return if (&filename_check($newfilename) ne 'ok'); if ($env{'form.action'} =~ /new(.+)file/) { my $extension=$1; - - ##Informs User (name).(number).(extension) not allowed - if($newfilename =~ /\.(\d+)\.(\w+)$/){ - $r->print(''.$newfilename. - ' - '.&mt('Bad Filename').''. + &mt('Invalid filename: ').&display($newfilename).'
'.
+ &mt('The name of the new file needs to end with an appropriate file extension to indicate the type of file to create.').'
'.
+ &mt('The following are valid extensions: [_1].',$validexts).
+ '
'. + '
'. + ''); + return; + } + $request->print(''.&mt('Make new file').' '.&display($newfilename).'?
'); $request->print(''); + $request->print(''); + '" method="post">'); $request->print(''); + '" method="post">'); + } + return; +} + +sub filename_check { + my ($newfilename) = @_; + ##Informs User (name).(number).(extension) not allowed + if($newfilename =~ /\.(\d+)\.(\w+)$/){ + $r->print(''.$newfilename. + ' - '.&mt('Bad Filename').'