[LON-CAPA-cvs] cvs: loncom /lonnet/perl lonuploadrep.pm /publisher loncfile.pm loncleanup.pm lonrights.pm

albertel lon-capa-cvs@mail.lon-capa.org
Wed, 20 Dec 2006 22:41:12 -0000


albertel		Wed Dec 20 17:41:12 2006 EDT

  Modified files:              
    /loncom/lonnet/perl	lonuploadrep.pm 
    /loncom/publisher	loncfile.pm loncleanup.pm lonrights.pm 
  Log:
  - bunch of \w replacements
  
  
Index: loncom/lonnet/perl/lonuploadrep.pm
diff -u loncom/lonnet/perl/lonuploadrep.pm:1.8 loncom/lonnet/perl/lonuploadrep.pm:1.9
--- loncom/lonnet/perl/lonuploadrep.pm:1.8	Mon Aug 21 11:21:31 2006
+++ loncom/lonnet/perl/lonuploadrep.pm	Wed Dec 20 17:41:07 2006
@@ -31,10 +31,11 @@
 use Apache::lonrep();
 use Apache::lonnet;
 use CGI::Cookie();
+use LONCAPA();
 
 sub handler {
     my $r = shift;
-    if ($r->uri =~m|^/*uploaded/(\w+)/(\w+)/(.+)$|) {
+    if ($r->uri =~m{^/*uploaded/($LONCAPA::domain_re)/($LONCAPA::name_re)/(.+)$}) {
         my $chome=&Apache::lonnet::homeserver($2,$1);
 	my @ids=&Apache::lonnet::current_machine_ids();
 	foreach my $id (@ids) { if ($id eq $chome) { return OK; } }
Index: loncom/publisher/loncfile.pm
diff -u loncom/publisher/loncfile.pm:1.79 loncom/publisher/loncfile.pm:1.80
--- loncom/publisher/loncfile.pm:1.79	Wed Nov 22 20:50:57 2006
+++ loncom/publisher/loncfile.pm	Wed Dec 20 17:41:08 2006
@@ -9,7 +9,7 @@
 #  and displays a page showing the results of the action.
 #
 #
-# $Id: loncfile.pm,v 1.79 2006/11/23 01:50:57 banghart Exp $
+# $Id: loncfile.pm,v 1.80 2006/12/20 22:41:08 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -72,9 +72,8 @@
 use Apache::lonnet;
 use Apache::loncommon();
 use Apache::lonlocal;
-use lib '/home/httpd/lib/perl/';
-use LONCAPA;
- 
+use LONCAPA qw(:DEFAULT :match);
+
 
 my $DEBUG=0;
 my $r;				# Needs to be global for some stuff RF.
@@ -151,21 +150,21 @@
     $Url=~ s/\/+/\//g;
     $Url=~ s/^http\:\/\/[^\/]+//;
     $Url=~ s/^\///;
-    $Url=~ s/(\~|priv\/)(\w+)\//\/home\/$2\/public_html\//;
+    $Url=~ s/(\~|priv\/)($match_username)\//\/home\/$2\/public_html\//;
     &Debug($r, "Returning $Url \n");
     return $Url;
 }
 
 sub url {
     my $fn=shift;
-    $fn=~s/^\/home\/(\w+)\/public\_html/\/priv\/$1/;
+    $fn=~s/^\/home\/($match_username)\/public\_html/\/priv\/$1/;
     $fn=&HTML::Entities::encode($fn,'<>"&');
     return $fn;
 }
 
 sub display {
     my $fn=shift;
-    $fn=~s-^/home/(\w+)/public_html-/priv/$1-;
+    $fn=~s-^/home/($match_username)/public_html-/priv/$1-;
     return '<tt>'.$fn.'</tt>';
 }
 
Index: loncom/publisher/loncleanup.pm
diff -u loncom/publisher/loncleanup.pm:1.8 loncom/publisher/loncleanup.pm:1.9
--- loncom/publisher/loncleanup.pm:1.8	Tue May 30 08:47:41 2006
+++ loncom/publisher/loncleanup.pm	Wed Dec 20 17:41:08 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to cleanup XML files
 #
-# $Id: loncleanup.pm,v 1.8 2006/05/30 12:47:41 www Exp $
+# $Id: loncleanup.pm,v 1.9 2006/12/20 22:41:08 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -362,7 +362,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/lonrights.pm
diff -u loncom/publisher/lonrights.pm:1.20 loncom/publisher/lonrights.pm:1.21
--- loncom/publisher/lonrights.pm:1.20	Thu Nov  9 17:48:50 2006
+++ loncom/publisher/lonrights.pm	Wed Dec 20 17:41:08 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to show and edit custom distribution rights
 #
-# $Id: lonrights.pm,v 1.20 2006/11/09 22:48:50 raeburn Exp $
+# $Id: lonrights.pm,v 1.21 2006/12/20 22:41:08 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -89,8 +89,8 @@
 		          ($rulehash{'effect'} eq 'allow')) {
 		      $rulehash{'effect'}='deny';
                   }
-                  $rulehash{'domain'}=~s/\W//g;
-                  $rulehash{'course'}=~s/\W//g;
+                  $rulehash{'domain'} = &LONCAPA::clean_domain($rulehash{'domain'});
+		  $rulehash{'course'} = &LONCAPA::clean_courseid($rulehash{'course'});
                   $rulehash{'section'}=~s/\W//g;
                   unless ($rulehash{'domain'}) { 
                      $rulehash{'domain'}=$env{'user.domain'}; 
@@ -243,8 +243,9 @@
 	  $r->print('</td><td>');
 # ---- realm
           my $realm=$token->[2]->{'realm'};
-          $realm=~s/^\W//;
           my ($rdom,$rcourse,$rsec)=split(/[\/\_]/,$realm);
+	  $rdom = &LONCAPA::clean_domain($rdom);
+	  $rcourse = &LONCAPA::clean_courseid($rcourse);
 # realm domain
           if ($constructmode) {
               unless ($rdom) { $rdom=$env{'user.domain'}; }