From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <pve-devel-bounces@lists.proxmox.com> Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 152B11FF164 for <inbox@lore.proxmox.com>; Fri, 23 May 2025 14:26:38 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id AF40519E9A; Fri, 23 May 2025 14:26:26 +0200 (CEST) From: Lukas Wagner <l.wagner@proxmox.com> To: pve-devel@lists.proxmox.com Date: Fri, 23 May 2025 14:26:15 +0200 Message-Id: <20250523122615.251430-7-l.wagner@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250523122615.251430-1-l.wagner@proxmox.com> References: <20250523122615.251430-1-l.wagner@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.020 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH proxmox 3/3] notify: update mail-parser dependency to 0.11 X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com> List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe> List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/> List-Post: <mailto:pve-devel@lists.proxmox.com> List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help> List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe> Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com> 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.wagner@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