[LON-CAPA-cvs] cvs: loncom /lonnet/perl lonnet.pm

albertel lon-capa-cvs-allow@mail.lon-capa.org
Wed, 05 Dec 2007 20:08:52 -0000


albertel		Wed Dec  5 15:08:52 2007 EDT

  Modified files:              
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - remove a possible infinte loop (for file location '/../../test'
  - optimize re so it doesn't spend foerever backtracking on failures
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.929 loncom/lonnet/perl/lonnet.pm:1.930
--- loncom/lonnet/perl/lonnet.pm:1.929	Wed Dec  5 15:06:34 2007
+++ loncom/lonnet/perl/lonnet.pm	Wed Dec  5 15:08:52 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.929 2007/12/05 20:06:34 albertel Exp $
+# $Id: lonnet.pm,v 1.930 2007/12/05 20:08:52 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1635,7 +1635,7 @@
                                      &ssi($filelink,%form));
     $output=~s|//(\s*<!--)? BEGIN LON-CAPA Internal.+?// END LON-CAPA Internal\s*(-->)?\s||gs;
     $output=~s/^.*?\<body[^\>]*\>//si;
-    $output=~s/(.*)\<\/body\s*\>.*?$/$1/si;
+    $output=~s/\<\/body\s*\>.*?$//si;
     return $output;
 }
 
@@ -7973,7 +7973,13 @@
         }
     }
     $location=~s://+:/:g; # remove duplicate /
-    while ($location=~m:/\.\./:) {$location=~ s:/[^/]+/\.\./:/:g;} #remove dir/..
+    while ($location=~m{/\.\./}) {
+	if ($location =~ m{/[^/]+/\.\./}) {
+	    $location=~ s{/[^/]+/\.\./}{/}g;
+	} else {
+	    $location=~ s{/\.\./}{/}g;
+	}
+    } #remove dir/..
     while ($location=~m:/\./:) {$location=~ s:/\./:/:g;} #remove /./
     return $location;
 }