[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /imspackages imsprocessor.pm

raeburn raeburn at source.lon-capa.org
Mon Sep 3 08:43:00 EDT 2018


raeburn		Mon Sep  3 12:43:00 2018 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/imspackages	imsprocessor.pm 
  Log:
  - For 2.11
    Backport 1.56, 1.57, 1.58
  
  
Index: loncom/imspackages/imsprocessor.pm
diff -u loncom/imspackages/imsprocessor.pm:1.54 loncom/imspackages/imsprocessor.pm:1.54.4.1
--- loncom/imspackages/imsprocessor.pm:1.54	Thu Dec 11 01:12:14 2014
+++ loncom/imspackages/imsprocessor.pm	Mon Sep  3 12:43:00 2018
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Processor for IMS Packages
 #
-# $Id: imsprocessor.pm,v 1.54 2014/12/11 01:12:14 raeburn Exp $
+# $Id: imsprocessor.pm,v 1.54.4.1 2018/09/03 12:43:00 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -29,6 +29,7 @@
 package Apache::imsprocessor;
 
 use Apache::lonnet;
+use Apache::loncommon;
 use Apache::loncleanup;
 use Apache::lonlocal;
 use LWP::UserAgent;
@@ -99,6 +100,9 @@
     my ($context,$pathinfo,$timenow) = @_;   
     my $configvars = &LONCAPA::Configuration::read_conf('loncapa.conf');
     my $tempdir;
+    $pathinfo = &Apache::loncommon::clean_path($pathinfo);
+# Collapse dots
+    $pathinfo =~ s/\.+/./g;
     if ($context eq 'DOCS') {
         $tempdir =  $$configvars{'lonDaemons'}.'/tmp/'.$pathinfo;
         if (!-e "$tempdir") {
@@ -130,11 +134,13 @@
         $fname=~s/\s+/\_/g;
 # Replace all other weird characters by nothing
         $fname=~s/[^\w\.\-]//g;
+# Collapse dots
+        $fname=~s/\.+/./g;
 # See if there is anything left
         unless ($fname) { return 'error: no uploaded file'; }
 # Save the file
         chomp($env{'form.uploadname'});
-        open(my $fh,'>'.$tempdir.'/'.$fname);
+        open(my $fh,'>',"$tempdir/$fname");
         print $fh $env{'form.uploadname'};
         close($fh);
     } elsif ($context eq 'CSTR') {
@@ -988,10 +994,10 @@
                 $seqtext{$key} .= "</map>\n";
                 if ($cms eq 'webctce4' && $key ne 'Top') {
                     push @{$seqfiles}, "$seqtitle.sequence";
-                    open(LOCFILE,">$destdir/sequences/$seqtitle.sequence");
+                    open(LOCFILE,'>',"$destdir/sequences/$seqtitle.sequence");
                 } else {
                     push @{$seqfiles}, "$key.sequence";
-                    open(LOCFILE,">$destdir/sequences/$key.sequence");
+                    open(LOCFILE,'>',"$destdir/sequences/$key.sequence");
                 }
                 print LOCFILE $seqtext{$key};
                 close(LOCFILE);
@@ -1021,7 +1027,7 @@
             &process_specials($context,'pools',$pools,\$topnum,$$items{'Top'}{contentscount},$destdir,$udom,$uname,$cdom,$crs,$timenow,$newdir,$timestamp,$resinfo,\$seqtext{'Top'},$pagesfiles,$seqfiles,$topurls,$topnames);
         }
         $seqtext{'Top'} .= "</map>\n";
-        open(TOPFILE,">$destdir/sequences/Top.sequence");
+        open(TOPFILE,'>',"$destdir/sequences/Top.sequence");
         print TOPFILE $seqtext{'Top'};
         close(TOPFILE);
         push @{$seqfiles}, 'Top.sequence';
@@ -1043,7 +1049,7 @@
             if (grep/^$res$/,@{$packages}) {
                 $resource =  $filestem.'/resfiles/'.$res.'./index.html'; # should be entry_point
             }
-            open(PAGEFILE,">$filename");
+            open(PAGEFILE,'>',$filename);
             print PAGEFILE qq|<map>
 <resource src="$resource" id="1" type="start" title="$$items{$pagecontents{$key}[$i][0]}{title}"></resource>
 <link to="2" index="1" from="1">\n|;
@@ -1232,10 +1238,10 @@
 
     if ($type eq "announcements") {
         push @{$pagesfiles}, "$seqnames{$type}.page";
-        open(ITEM,">$destdir/pages/$seqnames{$type}.page");
+        open(ITEM,'>',"$destdir/pages/$seqnames{$type}.page");
     } else {
         push @{$seqfiles}, "$seqnames{$type}.sequence";
-        open(ITEM,">$destdir/sequences/$seqnames{$type}.sequence");
+        open(ITEM,'>',"$destdir/sequences/$seqnames{$type}.sequence");
     }
 
     if ($type eq 'boards') {
@@ -1578,7 +1584,7 @@
   </tr>
 </table>
     |;
-    open(FILE,">$destdir/resfiles/$res.html");
+    open(FILE,'>',"$destdir/resfiles/$res.html");
     push @{$resrcfiles}, "$res.html";
     print FILE qq|<html>
 <head>
@@ -1657,7 +1663,7 @@
         $linktag .= qq|>$$settings{title}</a>|;
     }
 
-    open(FILE,">$destdir/resfiles/$res.html");
+    open(FILE,'>',"$destdir/resfiles/$res.html");
     push @{$resrcfiles}, "$res.html";
     print FILE qq|<html>
 <head>
@@ -3393,7 +3399,7 @@
     my $curr_id = 0;
     my $next_id = 1;
     my $fh;
-    open($fh,">$destdir/sequences/question_database.sequence");
+    open($fh,'>',"$destdir/sequences/question_database.sequence");
     push @{$sequencesfiles},'question_database.sequence';
     foreach my $category (sort(keys(%{$catinfo}))) {
         my $seqname;
@@ -3459,7 +3465,7 @@
         if (!-e "$seqdir") {
             mkdir("$seqdir",0770);
         }
-        open($fh,">$$containerdir");
+        open($fh,'>',$$containerdir);
         $$total{seq} ++;
         push @{$sequencesfiles},$mapname.'.sequence';
     } else {
@@ -3467,7 +3473,7 @@
         if (!-e "$pagedir") {
             mkdir("$pagedir",0770);
         }
-        open($fh,">$$containerdir");
+        open($fh,'>',$$containerdir);
         $$total{page} ++;
         push @{$pagesfiles},$mapname.'.page';
     }
@@ -3925,7 +3931,7 @@
             $title =~ s/\s/_/g;
             $title =~ s/\W//g;
             $title .= '_'.$id;
-            open(PROB,">$newdir/$title.problem");
+            open(PROB,'>',"$newdir/$title.problem");
             print PROB $output;
             close PROB;
         } else {
@@ -4543,7 +4549,7 @@
             $title =~ s/\s/_/g;
             $title =~ s/:/_/g;
             $title =~ s/\//_/g;
-            open(PROB,">$destdir/problems/$probdir/$title.problem");
+            open(PROB,'>',"$destdir/problems/$probdir/$title.problem");
             print PROB $output;
             close PROB;
         } else {
@@ -4942,7 +4948,7 @@
             $title =~ s/\s/_/g;
             $title =~ s/\W//g;
             $title .= '_'.$id;
-            open(PROB,">$newdir/$title.problem");
+            open(PROB,'>',"$newdir/$title.problem");
             print PROB $output;
             close PROB;
         } else {
@@ -4968,7 +4974,7 @@
         if (!-e "$docroot/$res/webimages") {
             mkdir("$docroot/$res/webimages",0755);
         }
-        open(my $fh,">$docroot/$res/webimages/$filename");
+        open(my $fh,'>',"$docroot/$res/webimages/$filename");
         print $fh $contents;
         close($fh);
         if ($context eq 'DOCS') {
@@ -5061,7 +5067,7 @@
         }
     }
 
-    open(FILE,">$destdir/resfiles/$res.html");
+    open(FILE,'>',"$destdir/resfiles/$res.html");
     push @{$resrcfiles}, "$res.html";
     print FILE qq|<html>
 <head>
@@ -5267,7 +5273,7 @@
         }
     }
 
-    if (!open(FILE,">$destdir/resfiles/$res.html")) {
+    if (!open(FILE,'>',"$destdir/resfiles/$res.html")) {
         &Apache::lonnet::logthis("IMS import error: Cannot open file - $destdir/resfiles/$res.html - $!");
     } else {
         push @{$resrcfiles}, "$res.html";
@@ -5460,7 +5466,7 @@
     $p->parse_file($xmlfile);
     $p->eof;
     if ($type eq "PAGE") {
-        open(FILE,"<$xmlfile");
+        open(FILE,'<',$xmlfile);
         @buffer = <FILE>;
         close(FILE);
         chomp(@buffer);
@@ -5477,7 +5483,7 @@
             }
         }
     }
-    open(FILE,">$destdir/resfiles/$res.html");
+    open(FILE,'>',"$destdir/resfiles/$res.html");
     push @{$resrcfiles}, "$res.html";
     print FILE qq|<html>
 <head>
@@ -5513,7 +5519,7 @@
 sub webct4_content {
     my ($res,$docroot,$destdir,$settings,$dom,$user,$type,$title,$resrcfiles) = @_;
     if (defined($$settings{url})) {
-        if (!open(FILE,">$destdir/resfiles/$res.html")) {
+        if (!open(FILE,'>',"$destdir/resfiles/$res.html")) {
             &Apache::lonnet::logthis("IMS import error: Cannot open file - $destdir/resfiles/$res.html - $!");
         } else {
             push(@{$resrcfiles}, "$res.html");




More information about the LON-CAPA-cvs mailing list