You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by do...@apache.org on 2006/07/11 05:44:32 UTC

svn commit: r420695 - /spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm

Author: dos
Date: Mon Jul 10 20:44:32 2006
New Revision: 420695

URL: http://svn.apache.org/viewvc?rev=420695&view=rev
Log:
bug 4978: fudge out of range times in parse_rfc822_date() to get usable date

Modified:
    spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm?rev=420695&r1=420694&r2=420695&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm Mon Jul 10 20:44:32 2006
@@ -421,12 +421,38 @@
   # Time::Local (v1.10 at least) throws warnings when the dates cause
   # a 32-bit overflow.  So force a min/max for year.
   if ($yyyy > 2037) {
-    dbg("util: date after supported range, forcing year to 2037: $date");
+    dbg("util: year after supported range, forcing year to 2037: $date");
     $yyyy = 2037;
   }
   elsif ($yyyy < 1970) {
-    dbg("util: date before supported range, forcing year to 1970: $date");
+    dbg("util: year before supported range, forcing year to 1970: $date");
     $yyyy = 1971;
+  }
+
+  # Fudge invalid times so that we get a usable date.
+  if ($ss > 59) { 
+    dbg("util: second after supported range, forcing second to 59: $date");  
+    $ss = 59;
+  } 
+  elsif ($ss < 0) {
+    dbg("util: second before supported range, forcing second to 00: $date");
+    $ss = "00";
+  }
+  if ($mm > 59) { 
+    dbg("util: minute after supported range, forcing minute to 59: $date");
+    $mm = 59;
+  }
+  elsif ($mm < 0) {   
+    dbg("util: minute before supported range, forcing minute to 00: $date");
+    $mm = "00";
+  }
+  if ($hh > 23) { 
+    dbg("util: hour after supported range, forcing hour to 23: $date"); 
+    $hh = 23;
+  }
+  elsif ($hh < 0) {
+    dbg("util: hour before supported range, forcing hour to 00: $date"); 
+    $hh = "00";
   }
 
   my $time;