Skip to content

Commit

Permalink
fix mailto parsing issue
Browse files Browse the repository at this point in the history
  • Loading branch information
soywod committed Nov 29, 2024
1 parent eafeeb2 commit 7aa5764
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 26 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
42 changes: 18 additions & 24 deletions src/email/message/command/mailto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 _},
Expand Down Expand Up @@ -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::<u8>::new();
let mut body = Vec::<u8>::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();

Expand Down

0 comments on commit 7aa5764

Please sign in to comment.