--- loncom/interface/londocs.pm 2006/11/30 23:34:38 1.262 +++ loncom/interface/londocs.pm 2007/01/05 16:40:27 1.265 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.262 2006/11/30 23:34:38 banghart Exp $ +# $Id: londocs.pm,v 1.265 2007/01/05 16:40:27 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -42,7 +42,7 @@ use HTML::Entities; use GDBM_File; use Apache::lonlocal; use Cwd; -use LONCAPA; +use LONCAPA qw(:DEFAULT :match); my $iconpath; @@ -99,7 +99,7 @@ sub authorhosts { $ca=$env{'user.name'}; $cd=$env{'user.domain'}; } else { - ($cd,$ca)=($realm=~/^\/(\w+)\/(\w+)$/); + ($cd,$ca)=($realm=~/^\/($match_domain)\/($match_username)$/); } my $allowed=0; my $myhome=&Apache::lonnet::homeserver($ca,$cd); @@ -366,7 +366,7 @@ sub exportcourse { if (ref($curRes)) { my $symb = $curRes->symb(); my $ressymb = $symb; - if ($ressymb =~ m|adm/(\w+)/(\w+)/(\d+)/bulletinboard$|) { + if ($ressymb =~ m|adm/($match_domain)/($match_username)/(\d+)/bulletinboard$|) { unless ($ressymb =~ m|adm/wrapper/adm|) { $ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3.'/bulletinboard'; } @@ -613,7 +613,7 @@ sub build_package { if (grep/^$count$/,@$discussions) { my $ressymb = $symb; my $mode; - if ($ressymb =~ m|adm/(\w+)/(\w+)/(\d+)/bulletinboard$|) { + if ($ressymb =~ m|adm/($match_domain)/($match_username)/(\d+)/bulletinboard$|) { unless ($ressymb =~ m|adm/wrapper/adm|) { $ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3.'/bulletinboard'; } @@ -698,7 +698,7 @@ sub process_content { } } elsif ($symb =~ m-lib/templates/examupload\.problem$-) { $content_type = 'examupload'; - } elsif ($symb =~ m-adm/(\w+)/(\w+)/(\d+)/bulletinboard$-) { + } elsif ($symb =~ m-adm/($match_domain)/($match_username)/(\d+)/bulletinboard$-) { $content_type = 'bulletinboard'; my $contents = &Apache::imsexport::templatedpage($content_type,$3,$count,\@uploads,$1,$2); if ($contents) { @@ -913,7 +913,7 @@ sub group_import { while (@_) { my $name = shift; my $url = shift; - if (($url =~ m#^/uploaded/$coursedom/$coursenum/(default_\d+\.)(page|sequence)$#) && ($caller eq 'londocs')) { + if (($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$}) && ($caller eq 'londocs')) { my $errtext = ''; my $fatal = 0; my $newmapstr = ''."\n". @@ -936,7 +936,7 @@ sub group_import { my $idx = &LONCAPA::map::getresidx($url); $LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx; my $ext = 'false'; - if ($url=~/^http:\/\// || $url=~/^https:\/\//) { $ext = 'true'; } + if ($url=~m{^http://} || $url=~m{^https://}) { $ext = 'true'; } $url =~ s/:/\:/g; $name =~ s/:/\:/g; $LONCAPA::map::resources[$idx] = @@ -1309,7 +1309,7 @@ sub editor { $url=~/^(.+)\.(\w+)$/; my $newurl=$1.$newid.'.'.$2; my $storefn=$newurl; - $storefn=~s/^\/\w+\/\w+\/\w+\///; + $storefn=~s{^/\w+/$match_domain/$match_username/}{}; &Apache::lonclonecourse::writefile ($env{'request.course.id'},$storefn, &Apache::lonnet::getfile($url)); @@ -1617,7 +1617,7 @@ sub process_secondary_uploads { $destination .= $newidx; my ($url,$filename); $url=&Apache::lonnet::userfileupload($formname.$num,1,$destination); - ($filename) = ($url =~ m-^/uploaded/$coursedom/$coursenum/$destination/(.+)$-); + ($filename) = ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/\Q$destination\E/(.+)$}); return $filename; } @@ -1632,7 +1632,7 @@ sub entryline { my $foldertitle=$title; my $pagetitle=$title; my $orderidx=$LONCAPA::map::order[$index]; - if ($title=~ /^(\d+)___&&&___(\w+)___&&&___(\w+)___&&&___(.*)$/ ) { + if ($title=~ /^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/ ) { $foldertitle=&Apache::lontexconvert::msgtexconverted($4); $renametitle=$4; $title=''.&Apache::lonlocal::locallocaltime($1).' '. @@ -1783,13 +1783,13 @@ END if ($uploaded) { if ($extension eq 'sequence') { $icon=$iconpath.'/folder_closed.gif'; - $url=~/$coursenum\/([\/\w]+)\.sequence$/; + $url=~/\Q$coursenum\E\/([\/\w]+)\.sequence$/; $url='/adm/coursedocs?'; $folderarg=$1; $isfolder=1; } elsif ($extension eq 'page') { $icon=$iconpath.'/page.gif'; - $url=~/$coursenum\/([\/\w]+)\.page$/; + $url=~/\Q$coursenum\E\/([\/\w]+)\.page$/; $pagearg=$1; $url='/adm/coursedocs?'; $ispage=1; @@ -2490,7 +2490,8 @@ sub handler { my %codebase = (); my ($upload_result,$upload_output); if ($allowed) { - if (($env{'form.uploaddoc.filename'}) && ($env{'form.cmd'}=~/^upload_(\w+)/)) { + if (($env{'form.uploaddoc.filename'}) && + ($env{'form.cmd'}=~/^upload_(\w+)/)) { # Process file upload - phase one - upload and parse primary file. $upload_result = &process_file_upload(\$upload_output,$coursenum, $coursedom,\%allfiles,