Skip to content

Commit 94376fa

Browse files
committed
handle invalid dates better
1 parent 1520e01 commit 94376fa

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

app/services/email_ingestor.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,14 @@ def add_mentions(msg, users)
348348
def sanitize_email_date(mail_date, mail_date_header, message_id)
349349
return mail_date if mail_date.nil?
350350

351+
unless mail_date.respond_to?(:utc)
352+
begin
353+
mail_date = Time.parse(mail_date.to_s)
354+
rescue ArgumentError, TypeError
355+
return Time.parse("2000-01-01 00:00:00 UTC")
356+
end
357+
end
358+
351359
current_time_utc = Time.now.utc
352360
mail_date_utc = mail_date.utc
353361
min_valid_date = Time.parse("1996-01-01 00:00:00 UTC")

0 commit comments

Comments
 (0)