From 7aa576400a239be971350955a7a180160c680be9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20DOUIN?= Date: Fri, 29 Nov 2024 11:58:00 +0100 Subject: [PATCH] fix mailto parsing issue --- CHANGELOG.md | 2 ++ Cargo.lock | 1 - Cargo.toml | 1 - src/email/message/command/mailto.rs | 42 +++++++++++++---------------- 4 files changed, 20 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 03da2c04..db8fbe0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -89,6 +89,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Fixed pre-release archives issue. [#492] +- Fixed mailto parsing issue. [core#10] ## [1.0.0-beta.4] - 2024-04-16 @@ -896,3 +897,4 @@ Few major concepts changed: [#492]: https://github.com/pimalaya/himalaya/issues/492 [#496]: https://github.com/pimalaya/himalaya/issues/496 +[core#10]: https://github.com/pimalaya/core/issues/10 diff --git a/Cargo.lock b/Cargo.lock index 9a643c41..5148feb9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1795,7 +1795,6 @@ dependencies = [ "color-eyre", "email-lib", "himalaya", - "mail-builder", "mml-lib", "once_cell", "pimalaya-tui", diff --git a/Cargo.toml b/Cargo.toml index 1da39ce7..ace5ecbe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,7 +42,6 @@ clap_complete = "4.4" clap_mangen = "0.2" color-eyre = "0.6" email-lib = { version = "=0.26", default-features = false, features = ["tokio-rustls", "derive", "thread"] } -mail-builder = "0.3" mml-lib = { version = "1", default-features = false, features = ["compiler", "interpreter", "derive"] } once_cell = "1.16" pimalaya-tui = { version = "=0.1", default-features = false, features = ["email", "path", "cli", "himalaya", "tracing", "sled"] } diff --git a/src/email/message/command/mailto.rs b/src/email/message/command/mailto.rs index 45bafb24..118a7c37 100644 --- a/src/email/message/command/mailto.rs +++ b/src/email/message/command/mailto.rs @@ -3,7 +3,6 @@ use std::sync::Arc; use clap::Parser; use color_eyre::Result; use email::{backend::feature::BackendFeatureSource, config::Config}; -use mail_builder::MessageBuilder; use pimalaya_tui::{ himalaya::{backend::BackendBuilder, editor}, terminal::{cli::printer::Printer, config::TomlConfig as _}, @@ -62,40 +61,35 @@ impl MessageMailtoCommand { .build() .await?; - let mut builder = MessageBuilder::new().to(self.url.path()); - let mut body = String::new(); + let mut msg = Vec::::new(); + let mut body = Vec::::new(); + + msg.extend(b"Content-Type: text/plain; charset=utf-8\r\n"); for (key, val) in self.url.query_pairs() { - match key { - key if key.eq_ignore_ascii_case("in-reply-to") => { - builder = builder.in_reply_to(val.to_string()); - } - key if key.eq_ignore_ascii_case("cc") => { - builder = builder.cc(val.to_string()); - } - key if key.eq_ignore_ascii_case("bcc") => { - builder = builder.bcc(val.to_string()); - } - key if key.eq_ignore_ascii_case("subject") => { - builder = builder.subject(val.to_string()); - } - key if key.eq_ignore_ascii_case("body") => { - body += &val; - } - _ => (), + if key.eq_ignore_ascii_case("body") { + body.extend(val.as_bytes()); + } else { + msg.extend(key.as_bytes()); + msg.extend(b": "); + msg.extend(val.as_bytes()); + msg.extend(b"\r\n"); } } - match account_config.find_full_signature() { - Some(ref sig) => builder = builder.text_body(body + "\n\n" + sig), - None => builder = builder.text_body(body), + msg.extend(b"\r\n"); + msg.extend(body); + + if let Some(sig) = account_config.find_full_signature() { + msg.extend(b"\r\n"); + msg.extend(sig.as_bytes()); } let tpl = account_config .generate_tpl_interpreter() .with_show_only_headers(account_config.get_message_write_headers()) .build() - .from_msg_builder(builder) + .from_bytes(msg) .await? .into();