mimeparser: do not squash NDN text parts into attachments

Text part usually contains an error message that we want to display in
the UI.
This commit is contained in:
link2xt
2022-07-10 18:18:45 +00:00
parent 2e009d1327
commit 32eb016ee7
4 changed files with 141 additions and 2 deletions

View File

@@ -535,7 +535,9 @@ impl MimeMessage {
self.parse_system_message_headers(context);
self.parse_avatar_headers(context).await;
self.parse_videochat_headers();
self.squash_attachment_parts();
if self.failure_report.is_none() {
self.squash_attachment_parts();
}
if let Some(ref subject) = self.get_subject() {
let mut prepend_subject = true;

View File

@@ -2659,7 +2659,7 @@ mod tests {
"shenauithz@testrun.org",
"Mr.un2NYERi1RM.lbQ5F9q-QyJ@tiscali.it",
include_bytes!("../test-data/message/tiscali_ndn.eml"),
Some("Delivery to at least one recipient failed."),
Some("Delivery status notification This is an automatically generated Delivery Status Notification. \n\nDelivery to the following recipients was aborted after 2 second(s):\n\n * shenauithz@testrun.org"),
)
.await;
}
@@ -2736,6 +2736,19 @@ mod tests {
.await;
}
/// Tests that text part is not squashed into OpenPGP attachment.
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_parse_ndn_with_attachment() {
test_parse_ndn(
"alice@example.org",
"bob@example.net",
"Mr.I6Da6dXcTel.TroC5J3uSDH@example.org",
include_bytes!("../test-data/message/ndn_with_attachment.eml"),
Some("Undelivered Mail Returned to Sender This is the mail system at host relay01.example.org.\n\nI'm sorry to have to inform you that your message could not\nbe delivered to one or more recipients. It's attached below.\n\nFor further assistance, please send mail to postmaster.\n\nIf you do so, please include this problem report. You can\ndelete your own text from the attached returned message.\n\n The mail system\n\n<bob@example.net>: host mx2.example.net[80.241.60.215] said: 552 5.2.2\n <bob@example.net>: Recipient address rejected: Mailbox quota exceeded (in\n reply to RCPT TO command)\n\n<bob2@example.net>: host mx1.example.net[80.241.60.212] said: 552 5.2.2\n <bob2@example.net>: Recipient address rejected: Mailbox quota\n exceeded (in reply to RCPT TO command)")
)
.await;
}
// ndn = Non Delivery Notification
async fn test_parse_ndn(
self_addr: &str,