]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/MsgTime.pm
msgtime: avoid obviously out-of-range dates (for now)
[public-inbox.git] / lib / PublicInbox / MsgTime.pm
index 479aaa4ecf132f5176d49ce54db6171769872666..9f4326442dd110d12a40f96595d3b2b2da7461aa 100644 (file)
@@ -38,7 +38,7 @@ sub str2date_zone ($) {
        if ($date =~ /(?:[A-Za-z]+,?\s+)? # day-of-week
                        ([0-9]+),?\s+  # dd
                        ([A-Za-z]+)\s+ # mon
-                       ([0-9]{2,})\s+ # YYYY or YY (or YYY :P)
+                       ([0-9]{2,4})\s+ # YYYY or YY (or YYY :P)
                        ([0-9]+)[:\.] # HH:
                                ((?:[0-9]{2})|(?:\s?[0-9])) # MM
                                (?:[:\.]((?:[0-9]{2})|(?:\s?[0-9])))? # :SS
@@ -67,6 +67,10 @@ sub str2date_zone ($) {
 
                $ts = timegm($ss // 0, $mm, $hh, $dd, $mon, $yyyy);
 
+               # 4-digit dates in non-spam from 1900s and 1910s exist in
+               # lore archives
+               return if $ts < 0;
+
                # Compute the time offset from [+-]HHMM
                $tz //= 0;
                my ($tz_hh, $tz_mm);