diff --git a/Cargo.toml b/Cargo.toml index 37f46124..8b0b4f93 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,8 +4,8 @@ workspace = { members = ["macros"] } name = "vaultwarden" version = "1.0.0" authors = ["Daniel GarcĂ­a "] -edition = "2021" -rust-version = "1.83.0" +edition = "2024" +rust-version = "1.85.0" resolver = "2" repository = "https://github.com/dani-garcia/vaultwarden" diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 5506e541..e9ff4098 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "1.84.1" +channel = "1.85" components = [ "rustfmt", "clippy" ] profile = "minimal" diff --git a/rustfmt.toml b/rustfmt.toml index 1d5e440f..a00d27e0 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,4 +1,4 @@ -edition = "2021" +edition = "2024" max_width = 120 newline_style = "Unix" use_small_heuristics = "Off" diff --git a/src/mail.rs b/src/mail.rs index 51ef9f73..3ecd0513 100644 --- a/src/mail.rs +++ b/src/mail.rs @@ -10,7 +10,7 @@ use lettre::{ Address, AsyncSendmailTransport, AsyncSmtpTransport, AsyncTransport, Tokio1Executor, }; use percent_encoding::{percent_encode, NON_ALPHANUMERIC}; -use std::{env::consts::EXE_SUFFIX, io::Read, str::FromStr}; +use std::{env::consts::EXE_SUFFIX, fs, str::FromStr}; use crate::{ api::EmptyResult, @@ -650,14 +650,12 @@ async fn send_email(address: &str, subject: &str, body_html: String, body_text: Some(true) => DkimSigningAlgorithm::Rsa, _ => DkimSigningAlgorithm::Ed25519, }; - let mut key = String::with_capacity(4096); - let sig = match std::fs::File::open(sig) { - Ok(mut f) => { - if let Err(e) = f.read_to_string(&mut key) { - debug!("Cannot read DKIM file. Err is {:?}", e); + let sig = match fs::read_to_string(sig) { + Err(e) => { + debug!("Cannot read DKIM file. Err is {:?}", e); None - } else { - key.shrink_to_fit(); + }, + Ok(key) => { match DkimSigningKey::new(&key, algo) { Ok(d) => Some(d), Err(e) => { @@ -666,11 +664,6 @@ async fn send_email(address: &str, subject: &str, body_html: String, body_text: } } } - }, - Err(e) => { - debug!("Cannot read DKIM file. Err is {:?}", e); - None - } }; match (sig, infos.split(':').collect::>()) { (Some(sig), split2) if split2.len() == 2 => {