mirror of
https://github.com/chatmail/core.git
synced 2026-04-02 05:22:14 +03:00
remove hack for decoding, and add a test that encoding/decoding works now
This commit is contained in:
@@ -185,7 +185,7 @@ jobs:
|
||||
- *restore-cache
|
||||
- run:
|
||||
name: Run cargo clippy
|
||||
command: cargo clippy --all
|
||||
command: cargo clippy
|
||||
|
||||
|
||||
workflows:
|
||||
|
||||
@@ -652,6 +652,7 @@ class TestOnlineAccount:
|
||||
msg_in = ac2.get_message_by_id(msg_out.id)
|
||||
assert msg_in.text == "message1"
|
||||
assert not msg_in.is_forwarded()
|
||||
assert msg_in.get_sender_contact().display_name == ac1.get_config("displayname")
|
||||
|
||||
lp.sec("check the message arrived in contact-requets/deaddrop")
|
||||
chat2 = msg_in.chat
|
||||
|
||||
@@ -1583,10 +1583,6 @@ fn dc_add_or_lookup_contacts_by_address_list(
|
||||
origin: Origin,
|
||||
to_ids: &mut ContactIds,
|
||||
) -> Result<()> {
|
||||
// XXX we use manual decoding
|
||||
// https://github.com/staktrace/mailparse/issues/50
|
||||
use email::rfc2047::decode_rfc2047;
|
||||
|
||||
let addrs = match mailparse::addrparse(addr_list_raw) {
|
||||
Ok(addrs) => addrs,
|
||||
Err(err) => {
|
||||
@@ -1601,22 +1597,18 @@ fn dc_add_or_lookup_contacts_by_address_list(
|
||||
for addr in addrs.iter() {
|
||||
match addr {
|
||||
mailparse::MailAddr::Single(info) => {
|
||||
// mailparse does not give us decoded vals
|
||||
let display_name = decode_rfc2047(&info.display_name.clone().unwrap_or_default());
|
||||
to_ids.insert(add_or_lookup_contact_by_addr(
|
||||
context,
|
||||
&display_name,
|
||||
&info.display_name,
|
||||
&info.addr,
|
||||
origin,
|
||||
)?);
|
||||
}
|
||||
mailparse::MailAddr::Group(infos) => {
|
||||
for info in &infos.addrs {
|
||||
let display_name =
|
||||
decode_rfc2047(&info.display_name.clone().unwrap_or_default());
|
||||
to_ids.insert(add_or_lookup_contact_by_addr(
|
||||
context,
|
||||
&display_name,
|
||||
&info.display_name,
|
||||
&info.addr,
|
||||
origin,
|
||||
)?);
|
||||
|
||||
@@ -1055,8 +1055,6 @@ pub fn needs_encoding(to_check: impl AsRef<str>) -> bool {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use email::rfc2047::decode_rfc2047;
|
||||
use mailparse::{addrparse, MailAddr};
|
||||
|
||||
#[test]
|
||||
fn test_render_email_address() {
|
||||
@@ -1071,20 +1069,7 @@ mod tests {
|
||||
);
|
||||
|
||||
println!("{}", s);
|
||||
assert!(s.is_ascii());
|
||||
|
||||
assert_eq!(s, "=?utf-8?q?=C3=A4_space?= <x@y.org>");
|
||||
|
||||
match &addrparse(&s).unwrap()[0] {
|
||||
MailAddr::Single(info) => {
|
||||
// XXX addrparse should not return rfc2047 encoding
|
||||
// but the decoded string, see
|
||||
// https://github.com/staktrace/mailparse/issues/50
|
||||
let s = decode_rfc2047(&info.display_name.clone().unwrap());
|
||||
assert_eq!(s, Some(display_name.to_string()));
|
||||
assert_eq!(info.addr, addr.to_string());
|
||||
}
|
||||
_ => panic!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user