mirror of
https://github.com/chatmail/core.git
synced 2026-04-26 18:06:35 +03:00
Use forked version of async-imap and imap-proto
This attempts to fix fetching when the inbox contains mail with non-utf8 subjects.
This commit is contained in:
committed by
holger krekel
parent
76de8f55f2
commit
6412adcfa7
@@ -799,9 +799,12 @@ unsafe fn handle_reports(
|
||||
&& !of_org_msgid.is_null()
|
||||
&& !(*of_org_msgid).fld_value.is_null()
|
||||
{
|
||||
if let Ok(rfc724_mid) = wrapmime::parse_message_id(
|
||||
&to_string_lossy((*of_org_msgid).fld_value),
|
||||
) {
|
||||
if let Ok(rfc724_mid) =
|
||||
wrapmime::parse_message_id(std::slice::from_raw_parts(
|
||||
(*of_org_msgid).fld_value as *const u8,
|
||||
libc::strlen((*of_org_msgid).fld_value),
|
||||
))
|
||||
{
|
||||
if let Some((chat_id, msg_id)) = message::mdn_from_ext(
|
||||
context,
|
||||
from_id,
|
||||
|
||||
@@ -49,20 +49,27 @@ pub fn get_ct_subtype(mime: *mut Mailmime) -> Option<String> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse_message_id(message_id: &str) -> Result<String, Error> {
|
||||
pub fn parse_message_id(message_id: &[u8]) -> Result<String, Error> {
|
||||
let mut dummy = 0;
|
||||
let c_message_id = CString::new(message_id).unwrap_or_default();
|
||||
let c_ptr = c_message_id.as_ptr();
|
||||
let mut rfc724_mid_c = std::ptr::null_mut();
|
||||
if unsafe { mailimf_msg_id_parse(c_ptr, libc::strlen(c_ptr), &mut dummy, &mut rfc724_mid_c) }
|
||||
== MAIL_NO_ERROR as libc::c_int
|
||||
if unsafe {
|
||||
mailimf_msg_id_parse(
|
||||
message_id.as_ptr() as *const i8,
|
||||
message_id.len(),
|
||||
&mut dummy,
|
||||
&mut rfc724_mid_c,
|
||||
)
|
||||
} == MAIL_NO_ERROR as libc::c_int
|
||||
&& !rfc724_mid_c.is_null()
|
||||
{
|
||||
let res = to_string_lossy(rfc724_mid_c);
|
||||
unsafe { libc::free(rfc724_mid_c.cast()) };
|
||||
Ok(res)
|
||||
} else {
|
||||
bail!("could not parse message_id: {}", message_id);
|
||||
bail!(
|
||||
"could not parse message_id: {}",
|
||||
String::from_utf8_lossy(message_id)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -543,11 +550,11 @@ mod tests {
|
||||
#[test]
|
||||
fn test_parse_message_id() {
|
||||
assert_eq!(
|
||||
parse_message_id("Mr.PRUe8HJBoaO.3whNvLCMFU0@testrun.org").unwrap(),
|
||||
parse_message_id(b"Mr.PRUe8HJBoaO.3whNvLCMFU0@testrun.org").unwrap(),
|
||||
"Mr.PRUe8HJBoaO.3whNvLCMFU0@testrun.org"
|
||||
);
|
||||
assert_eq!(
|
||||
parse_message_id("<Mr.PRUe8HJBoaO.3whNvLCMFU0@testrun.org>").unwrap(),
|
||||
parse_message_id(b"<Mr.PRUe8HJBoaO.3whNvLCMFU0@testrun.org>").unwrap(),
|
||||
"Mr.PRUe8HJBoaO.3whNvLCMFU0@testrun.org"
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user