Skip to content

Commit e9e1c3d

Browse files
committed
fix: use protected Date header when available
1 parent e5a3eae commit e9e1c3d

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/mimeparser.rs

+13-1
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ impl MimeMessage {
263263
// messages are shown as unencrypted anyway.
264264

265265
timestamp_sent =
266-
Self::get_timestamp_sent(&mail.headers, timestamp_sent, timestamp_rcvd);
266+
Self::get_timestamp_sent(&part.headers, timestamp_sent, timestamp_rcvd);
267267
MimeMessage::merge_headers(
268268
context,
269269
&mut headers,
@@ -351,6 +351,18 @@ impl MimeMessage {
351351
}
352352

353353
decrypted_msg = Some(msg);
354+
355+
if let Some(protected_timestamp_sent) = decrypted_mail
356+
.headers
357+
.get_header_value(HeaderDef::Date)
358+
.and_then(|v| mailparse::dateparse(&v).ok())
359+
{
360+
timestamp_sent = min(
361+
protected_timestamp_sent,
362+
timestamp_rcvd + constants::TIMESTAMP_SENT_TOLERANCE,
363+
)
364+
}
365+
354366
if let Some(protected_aheader_value) = decrypted_mail
355367
.headers
356368
.get_header_value(HeaderDef::Autocrypt)

0 commit comments

Comments
 (0)