[LON-CAPA-cvs] cvs: loncom / LONCAPA.pm lontrans.pm /interface lonpreferences.pm lonsearchcat.pm lonsupportreq.pm lontrackstudent.pm /interface/statistics lonproblemstatistics.pm /publisher lonpubdir.pm lonpublisher.pm lonretrieve.pm lonunauthorized.pm lonupload.pm testbankimport.pm

albertel lon-capa-cvs@mail.lon-capa.org
Wed, 06 Dec 2006 22:22:42 -0000


This is a MIME encoded message

--albertel1165443762
Content-Type: text/plain

albertel		Wed Dec  6 17:22:42 2006 EDT

  Modified files:              
    /loncom	LONCAPA.pm lontrans.pm 
    /loncom/interface	lonpreferences.pm lonsearchcat.pm 
                     	lonsupportreq.pm lontrackstudent.pm 
    /loncom/interface/statistics	lonproblemstatistics.pm 
    /loncom/publisher	lonpubdir.pm lonpublisher.pm lonretrieve.pm 
                     	lonunauthorized.pm lonupload.pm testbankimport.pm 
  Log:
  - more re fix ups
  
  
--albertel1165443762
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20061206172242.txt"

Index: loncom/LONCAPA.pm
diff -u loncom/LONCAPA.pm:1.17 loncom/LONCAPA.pm:1.18
--- loncom/LONCAPA.pm:1.17	Mon Dec  4 16:38:50 2006
+++ loncom/LONCAPA.pm	Wed Dec  6 17:22:36 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Base routines
 #
-# $Id: LONCAPA.pm,v 1.17 2006/12/04 21:38:50 albertel Exp $
+# $Id: LONCAPA.pm,v 1.18 2006/12/06 22:22:36 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -127,7 +127,7 @@
     return ($courseid =~ m/^$match_courseid$/);
 }
 
-$match_name  = qr{$match_username|$match_courseid};
+$match_name         = $LONCAPA::name = qr{$match_username|$match_courseid};
 sub clean_name {
     my ($name) = @_;
     $name =~ s/$match_not_username//g;
Index: loncom/lontrans.pm
diff -u loncom/lontrans.pm:1.12 loncom/lontrans.pm:1.13
--- loncom/lontrans.pm:1.12	Thu Aug 17 16:22:11 2006
+++ loncom/lontrans.pm	Wed Dec  6 17:22:36 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # URL translation for User Files
 #
-# $Id: lontrans.pm,v 1.12 2006/08/17 20:22:11 albertel Exp $
+# $Id: lontrans.pm,v 1.13 2006/12/06 22:22:36 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -32,7 +32,6 @@
 use Apache::Constants qw(:common :remotehost);
 use Apache::lonnet();
 use Apache::File();
-use lib '/home/httpd/lib/perl';
 use LONCAPA;
 
 
@@ -50,14 +49,14 @@
 	my @ids=&Apache::lonnet::current_machine_ids();
 	foreach my $id (@ids) { if ($id eq $chome) { $allowed=1; } }
 	if ($allowed) {
-            $r->filename(&propath($udom,$uname).
-                     '/userfiles/'.(join('/',@ufile)));
+	    $r->filename(&propath($udom,$uname).
+			 '/userfiles/'.(join('/',@ufile)));
         }
     } elsif ($r->uri=~m|^/~|) {	
 	#internal authentication, needs fixup.
 	my $fn = $r->uri(); # non users do not get the full path request
 	                 # through SCRIPT_FILENAME
-	$fn=~s|^/~(\w+)|/home/$1/public_html|;
+	$fn=~s|^/~($LONCAPA::username_re)|/home/$1/public_html|;
 	$r->filename($fn);
     } else { return DECLINED; }
     return OK;
Index: loncom/interface/lonpreferences.pm
diff -u loncom/interface/lonpreferences.pm:1.94 loncom/interface/lonpreferences.pm:1.95
--- loncom/interface/lonpreferences.pm:1.94	Mon Oct 23 17:22:51 2006
+++ loncom/interface/lonpreferences.pm	Wed Dec  6 17:22:37 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Preferences
 #
-# $Id: lonpreferences.pm,v 1.94 2006/10/23 21:22:51 raeburn Exp $
+# $Id: lonpreferences.pm,v 1.95 2006/12/06 22:22:37 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -42,6 +42,7 @@
 use Apache::lonhtmlcommon();
 use Apache::lonlocal;
 use Apache::lonnet;
+use LONCAPA();
 
 #
 # Write lonnet::passwd to do the call below.
@@ -553,8 +554,8 @@
     my $message='';
     foreach (split(/\,/,$env{'form.msgforward'})) {
 	my ($msuser,$msdomain)=split(/[\@\:]/,$_);
-        $msuser=~s/\W//g;
-        $msdomain=~s/\W//g;
+        $msuser = &LONCAPA::clean_username($msuser);
+        $msdomain = &LONCAPA::clean_domain($msdomain);
         if (($msuser) && ($msdomain)) {
 	    if (&Apache::lonnet::homeserver($msuser,$msdomain) ne 'no_host') {
                $newscreen.=$msuser.':'.$msdomain.',';
Index: loncom/interface/lonsearchcat.pm
diff -u loncom/interface/lonsearchcat.pm:1.277 loncom/interface/lonsearchcat.pm:1.278
--- loncom/interface/lonsearchcat.pm:1.277	Wed Sep 27 15:32:11 2006
+++ loncom/interface/lonsearchcat.pm	Wed Dec  6 17:22:37 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Search Catalog
 #
-# $Id: lonsearchcat.pm,v 1.277 2006/09/27 19:32:11 raeburn Exp $
+# $Id: lonsearchcat.pm,v 1.278 2006/12/06 22:22:37 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -78,7 +78,6 @@
 use Parse::RecDescent;
 use Apache::lonnavmaps;
 use Apache::lonindexer();
-use lib '/home/httpd/lib/perl/';
 use LONCAPA;
 
 ######################################################################
@@ -522,7 +521,7 @@
             my $applies = 0;
             my $symb = $resource->symb();
             my $ressymb = $symb;
-            if ($symb =~ m#(___adm/\w+/\w+)/(\d+)/bulletinboard$#) {
+            if ($symb =~ m#(___adm/$LONCAPA::domain_re/$LONCAPA::username_re)/(\d+)/bulletinboard$#) {
                 $ressymb = 'bulletin___'.$2.$1.'/'.$2.'/bulletinboard';
                 unless ($ressymb =~ m#bulletin___\d+___adm/wrapper#) {
                     $ressymb=~s#(bulletin___\d+___)#$1adm/wrapper/#;
Index: loncom/interface/lonsupportreq.pm
diff -u loncom/interface/lonsupportreq.pm:1.38 loncom/interface/lonsupportreq.pm:1.39
--- loncom/interface/lonsupportreq.pm:1.38	Thu Oct 12 18:47:31 2006
+++ loncom/interface/lonsupportreq.pm	Wed Dec  6 17:22:37 2006
@@ -1,5 +1,5 @@
 #
-# $Id: lonsupportreq.pm,v 1.38 2006/10/12 22:47:31 raeburn Exp $
+# $Id: lonsupportreq.pm,v 1.39 2006/12/06 22:22:37 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -37,7 +37,6 @@
 use Apache::lonlocal;
 use Apache::lonacc();
 use Apache::courseclassifier;
-use lib '/home/httpd/lib/perl/';
 use LONCAPA;
  
 
@@ -769,7 +768,7 @@
 
     my %cookies = ();
     my $cookie=CGI::Cookie->parse($r->header_in('Cookie'));
-    if ($$cookie{'lonID'} =~ /lonID=(\w+);/) {
+    if ($$cookie{'lonID'} =~ /lonID=($LONCAPA::handle_re);/) {
         $cookies{'lonID'} = $1;
     }
 
Index: loncom/interface/lontrackstudent.pm
diff -u loncom/interface/lontrackstudent.pm:1.20 loncom/interface/lontrackstudent.pm:1.21
--- loncom/interface/lontrackstudent.pm:1.20	Tue May 30 08:46:09 2006
+++ loncom/interface/lontrackstudent.pm	Wed Dec  6 17:22:37 2006
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lontrackstudent.pm,v 1.20 2006/05/30 12:46:09 www Exp $
+# $Id: lontrackstudent.pm,v 1.21 2006/12/06 22:22:37 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -537,9 +537,10 @@
         # For now, just show all the data, in the future allow selection of
         # a student
         my ($sname,$sdom) = split(':',$env{'form.selected_student'});
-        if ($sname =~ /^\w*$/ && $sdom =~ /^\w*$/) {
+        if ($sname =~ /^$LONCAPA::username_re$/ 
+	    && $sdom =~ /^$LONCAPA::domain_re$/) {
             $r->print('<h2>'.
-                      &mt('Recent activity of [_1]@[_2]',$sname,$sdom).
+                      &mt('Recent activity of [_1]:[_2]',$sname,$sdom).
                       '</h2>');
             $r->print('<p>'.&mt(<<END).'</p>');
 Compiling student activity data can take a long time.
@@ -548,7 +549,7 @@
             &get_data($r,\%prog_state,$navmap,
                       'student:'.$env{'form.selected_student'});
         } else {
-            $r->print('<h2>'.&mt('Unable to process for [_1]@[_2]',
+            $r->print('<h2>'.&mt('Unable to process for [_1]:[_2]',
                                  $sname,$sdom).'</h2>');
         }
     } else {
Index: loncom/interface/statistics/lonproblemstatistics.pm
diff -u loncom/interface/statistics/lonproblemstatistics.pm:1.110 loncom/interface/statistics/lonproblemstatistics.pm:1.111
--- loncom/interface/statistics/lonproblemstatistics.pm:1.110	Fri Aug 18 11:15:38 2006
+++ loncom/interface/statistics/lonproblemstatistics.pm	Wed Dec  6 17:22:38 2006
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonproblemstatistics.pm,v 1.110 2006/08/18 15:15:38 raeburn Exp $
+# $Id: lonproblemstatistics.pm,v 1.111 2006/12/06 22:22:38 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -60,7 +60,6 @@
 use Spreadsheet::WriteExcel;
 use Apache::lonstathelpers();
 use Time::HiRes;
-use lib '/home/httpd/lib/perl/';
 use LONCAPA;
  
 
@@ -1586,7 +1585,7 @@
         $data->{'urlres'}=$urlres;
         my %storestats = 
             &LONCAPA::lonmetadata::dynamic_metadata_storage($data);
-        my ($dom,$user) = $urlres=~/^(\w+)\/(\w+)/; 
+        my ($dom,$user) = ($urlres=~m{^($LONCAPA::domain_re)/($LONCAPA::username_re)}); 
         &Apache::lonnet::put('nohist_resevaldata',\%storestats,$dom,$user);
     }
     #
Index: loncom/publisher/lonpubdir.pm
diff -u loncom/publisher/lonpubdir.pm:1.97 loncom/publisher/lonpubdir.pm:1.98
--- loncom/publisher/lonpubdir.pm:1.97	Wed Nov 22 15:50:44 2006
+++ loncom/publisher/lonpubdir.pm	Wed Dec  6 17:22:39 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Construction Space Directory Lister
 #
-# $Id: lonpubdir.pm,v 1.97 2006/11/22 20:50:44 banghart Exp $
+# $Id: lonpubdir.pm,v 1.98 2006/12/06 22:22:39 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -41,6 +41,7 @@
 use Apache::lonmsg;
 use Apache::lonmenu;
 use Apache::lonnet;
+use LONCAPA;
 
 sub handler {
 
@@ -157,7 +158,7 @@
 	#
 	$fn=~s/^http\:\/\/[^\/]+\///;
         $fn=~s/^\///;
-        $fn=~s/\~(\w+)/\/home\/$1\/public_html/;
+        $fn=~s{~($LONCAPA::username_re)}{/home/$1/public_html};
 	
 	#  Remove trailing / strings (?) 
 	
@@ -170,7 +171,7 @@
 	    #internal authentication, needs fixup.
 	    $fn = $r->uri(); # non users do not get the full path request
                              # through SCRIPT_FILENAME
-	    $fn=~s|^/~(\w+)|/home/$1/public_html|;
+	    $fn=~s{^/~($LONCAPA::username_re)}{/home/$1/public_html};
 	}
     }
     $fn=~s/\/+/\//g;
@@ -514,9 +515,9 @@
 	%Apache::lonpublisher::metadatafields=();
 	%Apache::lonpublisher::metadatakeys=();
 	my $construct=$here;
-	$construct=~s:^/priv/(\w+)$:/home/$1/public_html:;
+	$construct=~s{^/priv/($LONCAPA::username_re)$}{/home/$1/public_html};
         my $dirpath = $here;
-        $dirpath=~s:^/priv/:/~:;
+        $dirpath=~s{^/priv/}{/~};
 	&Apache::lonpublisher::metaeval(&Apache::lonnet::getfile(
        				 $construct.'/'.$dirname.'/default.meta'
 								 ));
Index: loncom/publisher/lonpublisher.pm
diff -u loncom/publisher/lonpublisher.pm:1.214 loncom/publisher/lonpublisher.pm:1.215
--- loncom/publisher/lonpublisher.pm:1.214	Wed Sep 27 17:04:13 2006
+++ loncom/publisher/lonpublisher.pm	Wed Dec  6 17:22:39 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Publication Handler
 #
-# $Id: lonpublisher.pm,v 1.214 2006/09/27 21:04:13 albertel Exp $
+# $Id: lonpublisher.pm,v 1.215 2006/12/06 22:22:39 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -129,8 +129,7 @@
 use LONCAPA::lonmetadata;
 use Apache::lonmsg;
 use vars qw(%metadatafields %metadatakeys);
-use lib '/home/httpd/lib/perl/';
-use LONCAPA;
+use LONCAPA qw(:DEFAULT :match);
  
 
 my %addid;
@@ -281,9 +280,8 @@
 sub coursedependencies {
     my $url=&Apache::lonnet::declutter(shift);
     $url=~s/\.meta$//;
-    my ($adomain,$aauthor)=($url=~/^(\w+)\/(\w+)\//);
-    my $regexp=$url;
-    $regexp=~s/(\W)/\\$1/g;
+    my ($adomain,$aauthor)=($url=~ m{^($match_domain)/($match_username)/});
+    my $regexp=quotemeta($url);
     $regexp='___'.$regexp.'___course';
     my %evaldata=&Apache::lonnet::dump('nohist_resevaldata',$adomain,
 				       $aauthor,$regexp);
@@ -987,7 +985,7 @@
                    my %temphash=(&Apache::lonnet::declutter($target).'___'.
                              &Apache::lonnet::declutter($thisdep).'___usage'
                                  => time);
-                   $thisdep=~/^\/res\/(\w+)\/(\w+)\//;
+                   $thisdep=~m{^/res/($match_domain)/($match_username)/};
                    if ((defined($1)) && (defined($2))) {
                       &Apache::lonnet::put('nohist_resevaldata',\%temphash,
 					   $1,$2);
@@ -1669,7 +1667,7 @@
     unless ($batch) {
         
         my $thissrc=$source;
-        $thissrc=~s/^\/home\/(\w+)\/public_html/\/priv\/$1/;
+        $thissrc=~s{^/home/($match_username)/public_html}{/priv/$1};
         
         my $thissrcdir=$thissrc;
         $thissrcdir=~s/\/[^\/]+$/\//;
@@ -1994,8 +1992,8 @@
 	return HTTP_NOT_ACCEPTABLE;
     }
 
-    $fn=~s/^http\:\/\/[^\/]+//;
-    $fn=~s/^\/\~(\w+)/\/home\/$1\/public_html/;
+    $fn=~s{^http://[^/]+}{};
+    $fn=~s{^/~($match_username)}{/home/$1/public_html};
 
     my $targetdir='';
     $docroot=$r->dir_config('lonDocRoot'); 
Index: loncom/publisher/lonretrieve.pm
diff -u loncom/publisher/lonretrieve.pm:1.33 loncom/publisher/lonretrieve.pm:1.34
--- loncom/publisher/lonretrieve.pm:1.33	Fri Nov 10 13:01:08 2006
+++ loncom/publisher/lonretrieve.pm	Wed Dec  6 17:22:39 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to retrieve an old version of a file
 #
-# $Id: lonretrieve.pm,v 1.33 2006/11/10 18:01:08 albertel Exp $
+# $Id: lonretrieve.pm,v 1.34 2006/12/06 22:22:39 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -38,6 +38,7 @@
 use Apache::loncommon();
 use Apache::lonlocal;
 use Apache::lonnet;
+use LONCAPA();
 
 # ------------------------------------ Interface for selecting previous version
 sub phaseone {
@@ -242,7 +243,7 @@
      return HTTP_NOT_ACCEPTABLE;
   }
 
-  $fn=~s/\/\~(\w+)//;
+  $fn=~s{/~($LONCAPA::username_re)}{};
 
   &Apache::loncommon::content_type($r,'text/html');
   $r->send_http_header;
Index: loncom/publisher/lonunauthorized.pm
diff -u loncom/publisher/lonunauthorized.pm:1.5 loncom/publisher/lonunauthorized.pm:1.6
--- loncom/publisher/lonunauthorized.pm:1.5	Thu Apr  6 18:15:19 2006
+++ loncom/publisher/lonunauthorized.pm	Wed Dec  6 17:22:39 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Unauthorized to access construction space
 #
-# $Id: lonunauthorized.pm,v 1.5 2006/04/06 22:15:19 albertel Exp $
+# $Id: lonunauthorized.pm,v 1.6 2006/12/06 22:22:39 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -34,6 +34,7 @@
 use Apache::lonnet;
 use Apache::loncacc;
 use Apache::lonlocal;
+use LONCAPA();
 
 sub handler {
     my $r = shift;
@@ -66,19 +67,20 @@
         $r->print(
             "<h1>".
 	&mt("You do not have authoring privileges for this resource")."</h1>");
-        my ($realownername)=($env{'request.editurl'}=~/\/(?:\~|priv\/|home\/)(\w+)/);
+        my ($realownername)=
+	    ($env{'request.editurl'}=~m{/(?:~|priv/|home/)($LONCAPA::username_re)});
         my $realownerhome=
-      &Apache::lonnet::homeserver(
-        $realownername,$r->dir_config('lonDefDomain'));
+	    &Apache::lonnet::homeserver($realownername,
+					$r->dir_config('lonDefDomain'));
         unless ($realownerhome eq 'no_host') {
-           $r->print("<p>".&mt('Contact')." ".
+	    $r->print("<p>".&mt('Contact')." ".
     &Apache::loncommon::aboutmewrapper(
      &Apache::loncommon::plainname($realownername,
                                $r->dir_config('lonDefDomain')).' ('.
                                $realownername.&mt(' at ').
                                $r->dir_config('lonDefDomain').')',
 			       $realownername,$r->dir_config('lonDefDomain')).
-           ' for access.');
+           ' for access.</p>');
         }
     }
     
Index: loncom/publisher/lonupload.pm
diff -u loncom/publisher/lonupload.pm:1.33 loncom/publisher/lonupload.pm:1.34
--- loncom/publisher/lonupload.pm:1.33	Wed Jul  5 18:23:09 2006
+++ loncom/publisher/lonupload.pm	Wed Dec  6 17:22:39 2006
@@ -2,7 +2,7 @@
 # The LearningOnline Network with CAPA
 # Handler to upload files into construction space
 #
-# $Id: lonupload.pm,v 1.33 2006/07/05 22:23:09 albertel Exp $
+# $Id: lonupload.pm,v 1.34 2006/12/06 22:22:39 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -41,6 +41,7 @@
 use HTML::Entities();
 use Apache::lonlocal;
 use Apache::lonnet;
+use LONCAPA();
 
 my $DEBUG=0;
 
@@ -289,7 +290,7 @@
 	$fn=$env{'form.filename'};
 	$fn=~s/^http\:\/\/[^\/]+\///;
 	$fn=~s/^\///;
-	$fn=~s/(\~|priv\/)(\w+)//;
+	$fn=~s{(~|priv/)($LONCAPA::username_re)}{};
 	$fn=~s/\/+/\//g;
     } else {
 	$r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}.
Index: loncom/publisher/testbankimport.pm
diff -u loncom/publisher/testbankimport.pm:1.10 loncom/publisher/testbankimport.pm:1.11
--- loncom/publisher/testbankimport.pm:1.10	Mon Apr 10 18:30:31 2006
+++ loncom/publisher/testbankimport.pm	Wed Dec  6 17:22:39 2006
@@ -1,5 +1,5 @@
 # Handler for parsing text upload problem descriptions into .problems
-# $Id: testbankimport.pm,v 1.10 2006/04/10 22:30:31 albertel Exp $
+# $Id: testbankimport.pm,v 1.11 2006/12/06 22:22:39 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -35,6 +35,7 @@
 use Apache::lonlocal;
 use Apache::lonupload;
 use File::Basename();
+use LONCAPA();
 
 # ---------------------------------------------------------------- Display Control
 sub display_control {
@@ -1736,7 +1737,7 @@
         $fn=$env{'form.filename'};
         $fn=~s/^http\:\/\/[^\/]+\///;
         $fn=~s/^\///;
-        $fn=~s/(\~|priv\/)(\w+)//;
+        $fn=~s{(~|priv/)($LONCAPA::username_re)}{};
         $fn=~s/\/+/\//g;
     } else {
         $r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}.

--albertel1165443762--