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

albertel lon-capa-cvs@mail.lon-capa.org
Sat, 06 Nov 2004 01:14:05 -0000


albertel		Fri Nov  5 20:14:05 2004 EDT

  Modified files:              (Branch: version_1_2_X)
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - backport 1.562
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.523.2.8 loncom/lonnet/perl/lonnet.pm:1.523.2.9
--- loncom/lonnet/perl/lonnet.pm:1.523.2.8	Mon Sep 27 15:02:11 2004
+++ loncom/lonnet/perl/lonnet.pm	Fri Nov  5 20:14:05 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.523.2.8 2004/09/27 19:02:11 albertel Exp $
+# $Id: lonnet.pm,v 1.523.2.9 2004/11/06 01:14:05 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -4762,10 +4762,16 @@
     return &latest_rnd_algorithm_id();
 }
 
+sub validCODE {
+    my ($CODE)=@_;
+    if (defined($CODE) && $CODE ne '' && $CODE =~ /^\w+$/) { return 1; }
+    return 0;
+}
+
 sub getCODE {
-    if (defined($ENV{'form.CODE'})) { return $ENV{'form.CODE'}; }
+    if (&validCODE($ENV{'form.CODE'})) { return $ENV{'form.CODE'}; }
     if (defined($Apache::lonhomework::parsing_a_problem) &&
-	defined($Apache::lonhomework::history{'resource.CODE'})) {
+	&validCODE($Apache::lonhomework::history{'resource.CODE'})) {
 	return $Apache::lonhomework::history{'resource.CODE'};
     }
     return undef;