diff options
author | Eric Wong <e@80x24.org> | 2019-06-04 02:04:24 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2019-06-04 10:06:18 +0000 |
commit | 3703c8265f9294b8cff7172b62c8b923bcd8791a (patch) | |
tree | f6119604c142c90a5fb110dd40ba881f0060eb7c /lib/PublicInbox | |
parent | 7c29cce3cb92aeadc1ec589c96b36936e38fe8c1 (diff) | |
download | public-inbox-3703c8265f9294b8cff7172b62c8b923bcd8791a.tar.gz |
User input contains the darndest things. Don't waste more time than necessary trying to parse dates out of non-ASCII digits.
Diffstat (limited to 'lib/PublicInbox')
-rw-r--r-- | lib/PublicInbox/MsgTime.pm | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/PublicInbox/MsgTime.pm b/lib/PublicInbox/MsgTime.pm index 62160233..12412825 100644 --- a/lib/PublicInbox/MsgTime.pm +++ b/lib/PublicInbox/MsgTime.pm @@ -44,8 +44,9 @@ sub msg_received_at ($) { my @recvd = $hdr->header_raw('Received'); my ($ts); foreach my $r (@recvd) { - $r =~ /\s*(\d+\s+[[:alpha:]]+\s+\d{2,4}\s+ - \d+\D\d+(?:\D\d+)\s+([\+\-]\d+))/sx or next; + $r =~ /\s*([0-9]+\s+[a-zA-Z]+\s+[0-9]{2,4}\s+ + [0-9]+[^0-9][0-9]+(?:[^0-9][0-9]+) + \s+([\+\-][0-9]+))/sx or next; $ts = eval { str2date_zone($1) } and return $ts; my $mid = $hdr->header_raw('Message-ID'); warn "no date in $mid Received: $r\n"; @@ -59,7 +60,7 @@ sub msg_date_only ($) { my ($ts); foreach my $d (@date) { # Y2K problems: 3-digit years - $d =~ s!([A-Za-z]{3}) (\d{3}) (\d\d:\d\d:\d\d)! + $d =~ s!([A-Za-z]{3}) ([0-9]{3}) ([0-9]{2}:[0-9]{2}:[0-9]{2})! my $yyyy = $2 + 1900; "$1 $yyyy $3"!e; $ts = eval { str2date_zone($d) } and return $ts; if ($@) { |