From 449261bf41cc1e2b8b6949e4dc31b3cebbb35ab7 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Mon, 17 Sep 2018 12:45:17 +1200 Subject: [PATCH] Improve date handling in .eml files Handle a "Date:" header without the day of the week, which is allowed by RFC822 and RFC2822. If the date can't be parsed, just omit the date information rather than failing to process the file. (cherry picked from commit 461342b0070771c737b34e5b1f6c2464dfe6cb78) --- xapian-applications/omega/rfc822tohtml.in | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/xapian-applications/omega/rfc822tohtml.in b/xapian-applications/omega/rfc822tohtml.in index 5588506e4..abf01271d 100644 --- a/xapian-applications/omega/rfc822tohtml.in +++ b/xapian-applications/omega/rfc822tohtml.in @@ -3,7 +3,7 @@ # @file rfc822tohtml # @brief Extract HTML from an RFC-822 email # -# Copyright (C) 2010,2015 Olly Betts +# Copyright (C) 2010,2015,2018 Olly Betts # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to @@ -55,8 +55,12 @@ print "\">\n"; my $date = do_header($head, 'Date'); chomp $date; -$date = Time::Piece->strptime($date, '%a, %d %b %Y %T %z'); eval { + eval { + $date = Time::Piece->strptime($date, '%a, %d %b %Y %T %z'); + }; + # The "%a, " part is optional in RFC822 and RFC2822. + $date = Time::Piece->strptime($date, '%d %b %Y %T %z') if $@; my $iso8601_date = $date->datetime; print "\n"; }; -- 2.11.4.GIT