Thanks to the regression tests introduced in the previous commit we can
be certain that everything works as it should.

Signed-off-by: Lukas Wagner <l.wag...@proxmox.com>
---
 Cargo.toml                           |  2 +-
 proxmox-notify/src/endpoints/smtp.rs | 12 ++++++------
 proxmox-notify/src/lib.rs            |  3 ++-
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml
index 71763c5a..9b91dde0 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -90,7 +90,7 @@ ldap3 = { version = "0.11", default-features = false }
 lettre = "0.11.1"
 libc = "0.2.107"
 log = "0.4.17"
-mail-parser = "0.8.2"
+mail-parser = "0.11"
 native-tls = "0.2"
 nix = "0.26.1"
 openssl = "0.10"
diff --git a/proxmox-notify/src/endpoints/smtp.rs 
b/proxmox-notify/src/endpoints/smtp.rs
index 7ad85de8..b684d8ca 100644
--- a/proxmox-notify/src/endpoints/smtp.rs
+++ b/proxmox-notify/src/endpoints/smtp.rs
@@ -293,17 +293,16 @@ fn build_forwarded_message(
     use lettre::message::Body;
     use tracing::error;
 
-    let parsed_message = mail_parser::Message::parse(raw)
+    let parsed_message = mail_parser::MessageParser::default()
+        .parse(raw)
         .ok_or_else(|| Error::Generic("could not parse forwarded 
email".to_string()))?;
 
     let root_part = parsed_message
         .part(0)
         .ok_or_else(|| Error::Generic("root message part not 
present".to_string()))?;
 
-    let raw_body = parsed_message
-        .raw_message()
-        .get(root_part.offset_body..root_part.offset_end)
-        .ok_or_else(|| Error::Generic("could not get raw body 
content".to_string()))?;
+    let raw_body = &parsed_message.raw_message()
+        [root_part.offset_body as usize..root_part.offset_end as usize];
 
     // We assume that the original message content is already properly
     // encoded, thus we add the original message body in 'Binary' encoding.
@@ -345,7 +344,8 @@ fn build_forwarded_message(
                         use std::fmt::Write;
 
                         for attribute in attributes {
-                            let _ = write!(&mut value, "; {}=\"{}\"", 
attribute.0, attribute.1);
+                            let _ =
+                                write!(&mut value, "; {}=\"{}\"", 
attribute.name, attribute.value);
                         }
                     }
                     Some(value)
diff --git a/proxmox-notify/src/lib.rs b/proxmox-notify/src/lib.rs
index 12e59474..38d21618 100644
--- a/proxmox-notify/src/lib.rs
+++ b/proxmox-notify/src/lib.rs
@@ -232,7 +232,8 @@ impl Notification {
     }
     #[cfg(feature = "mail-forwarder")]
     pub fn new_forwarded_mail(raw_mail: &[u8], uid: Option<u32>) -> 
Result<Self, Error> {
-        let message = mail_parser::Message::parse(raw_mail)
+        let message = mail_parser::MessageParser::default()
+            .parse(raw_mail)
             .ok_or_else(|| Error::Generic("could not parse forwarded 
email".to_string()))?;
 
         let title = message.subject().unwrap_or_default().into();
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to