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

www lon-capa-cvs@mail.lon-capa.org
Tue, 07 May 2002 19:16:15 -0000


www		Tue May  7 15:16:15 2002 EDT

  Modified files:              
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  Towards verification and de-versioning of symbs
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.212 loncom/lonnet/perl/lonnet.pm:1.213
--- loncom/lonnet/perl/lonnet.pm:1.212	Mon May  6 09:52:53 2002
+++ loncom/lonnet/perl/lonnet.pm	Tue May  7 15:16:15 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.212 2002/05/06 13:52:53 www Exp $
+# $Id: lonnet.pm,v 1.213 2002/05/07 19:16:15 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1139,6 +1139,7 @@
 
     if ($stuname) { $home=&homeserver($stuname,$domain); }
 
+    $symb=&symbclean($symb);
     if (!$symb) { unless ($symb=&symbread()) { return ''; } }
 
     &devalidate($symb);
@@ -1169,6 +1170,7 @@
 
     if ($stuname) { $home=&homeserver($stuname,$domain); }
 
+    $symb=&symbclean($symb);
     if (!$symb) { unless ($symb=&symbread()) { return ''; } }
 
     &devalidate($symb);
@@ -1204,7 +1206,7 @@
     if (!$symb) {
       unless ($symb=escape(&symbread())) { return ''; }
     } else {
-      $symb=&escape($symb);
+      $symb=&escape(&symbclean($symb));
     }
     if (!$namespace) { 
        unless ($namespace=$ENV{'request.course.id'}) { 
@@ -2521,17 +2523,39 @@
 
 sub symbverify {
     my ($symb,$thisfn)=@_;
+    $thisfn=&declutter($thisfn);
+
+#    &logthis("Symb verify: $symb $thisfn");
+
+    my ($map,$resid,$url)=split(/\_\_\_/,$symb);
+    unless (&symbclean($url) eq &symbclean($thisfn)) { return 0; }
+
     return 1;
+
+    my %bighash;
+    my $okay=0;
+    if (tie(%bighash,'GDBM_File',$ENV{'request.course.fn'}.'.db',
+                            &GDBM_READER,0640)) {
+        
+	untie(%bighash);
+    }
+    return $okay;
 }
 
 # --------------------------------------------------------------- Clean-up symb
 
 sub symbclean {
     my $symb=shift;
+
+#    &logthis("Symb in: $symb");
+
 # remove version from map
     $symb=~s/\.(\d+)\.(\w+)\_\_\_/\.$2\_\_\_/;
 # remove version from URL
     $symb=~s/\.(\d+)\.(\w+)$/\.$2/;
+
+#    &logthis("Symb out: $symb");
+
     return $symb;
 }