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 23:50:38 UTC

svn commit: r421000 - /spamassassin/branches/3.1/lib/Mail/SpamAssassin/Util.pm

Author: dos
Date: Tue Jul 11 14:50:37 2006
New Revision: 421000

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

Modified:
    spamassassin/branches/3.1/lib/Mail/SpamAssassin/Util.pm

Modified: spamassassin/branches/3.1/lib/Mail/SpamAssassin/Util.pm
URL: http://svn.apache.org/viewvc/spamassassin/branches/3.1/lib/Mail/SpamAssassin/Util.pm?rev=421000&r1=420999&r2=421000&view=diff
==============================================================================
--- spamassassin/branches/3.1/lib/Mail/SpamAssassin/Util.pm (original)
+++ spamassassin/branches/3.1/lib/Mail/SpamAssassin/Util.pm Tue Jul 11 14:50:37 2006
@@ -416,12 +416,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;