[LON-CAPA-cvs] cvs: loncom /localize lonlocal.pm

raeburn lon-capa-cvs-allow@mail.lon-capa.org
Wed, 02 Jul 2008 21:31:32 -0000


raeburn		Wed Jul  2 17:31:32 2008 EDT

  Modified files:              
    /loncom/localize	lonlocal.pm 
  Log:
  Bug 5638.
   - Sanity checking of $thistime passed to locallocaltime(), before calling DateTime->from_epoch() to prevent ISE.
  
  
Index: loncom/localize/lonlocal.pm
diff -u loncom/localize/lonlocal.pm:1.46 loncom/localize/lonlocal.pm:1.47
--- loncom/localize/lonlocal.pm:1.46	Wed Jul  2 17:10:41 2008
+++ loncom/localize/lonlocal.pm	Wed Jul  2 17:31:32 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Localization routines
 #
-# $Id: lonlocal.pm,v 1.46 2008/07/02 21:10:41 raeburn Exp $
+# $Id: lonlocal.pm,v 1.47 2008/07/02 21:31:32 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -293,6 +293,14 @@
     if (!defined($thistime) || $thistime eq '') {
 	return &mt('Never');
     }
+    if (($thistime < 0) || ($thistime eq 'NaN')) {
+        &Apache::lonnet::logthis("Unexpected time (negative or NaN) '$thistime' passed to lonlocal::locallocaltime");  
+        return &mt('Never');
+    }
+    if ($thistime !~ /^\d+$/) {
+        &Apache::lonnet::logthis("Unexpected non-numeric time '$thistime' passed to lonlocal::locallocaltime");
+        return &mt('Never');
+    }
 
     my $dt = DateTime->from_epoch(epoch => $thistime)
                      ->set_time_zone(&gettimezone());