mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 17:36:29 +03:00
cargo fmt only
This commit is contained in:
@@ -587,7 +587,8 @@ impl<'a> MimeParser<'a> {
|
|||||||
if (*mime_data).dt_type != MAILMIME_DATA_TEXT as libc::c_int
|
if (*mime_data).dt_type != MAILMIME_DATA_TEXT as libc::c_int
|
||||||
/* MAILMIME_DATA_FILE indicates, the data is in a file; AFAIK this is not used on parsing */
|
/* MAILMIME_DATA_FILE indicates, the data is in a file; AFAIK this is not used on parsing */
|
||||||
|| (*mime_data).dt_data.dt_text.dt_data.is_null()
|
|| (*mime_data).dt_data.dt_text.dt_data.is_null()
|
||||||
|| (*mime_data).dt_data.dt_text.dt_length <= 0 {
|
|| (*mime_data).dt_data.dt_text.dt_length <= 0
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -621,14 +622,12 @@ impl<'a> MimeParser<'a> {
|
|||||||
/* get from `Content-Type: text/...; charset=utf-8`; must not be free()'d */
|
/* get from `Content-Type: text/...; charset=utf-8`; must not be free()'d */
|
||||||
let charset = mailmime_content_charset_get((*mime).mm_content_type);
|
let charset = mailmime_content_charset_get((*mime).mm_content_type);
|
||||||
if !charset.is_null()
|
if !charset.is_null()
|
||||||
&& strcmp(charset, b"utf-8\x00" as *const u8 as *const libc::c_char)
|
&& strcmp(charset, b"utf-8\x00" as *const u8 as *const libc::c_char) != 0i32
|
||||||
!= 0i32
|
&& strcmp(charset, b"UTF-8\x00" as *const u8 as *const libc::c_char) != 0i32
|
||||||
&& strcmp(charset, b"UTF-8\x00" as *const u8 as *const libc::c_char)
|
{
|
||||||
!= 0i32
|
if let Some(encoding) =
|
||||||
|
Charset::for_label(CStr::from_ptr(charset).to_str().unwrap().as_bytes())
|
||||||
{
|
{
|
||||||
if let Some(encoding) = Charset::for_label(
|
|
||||||
CStr::from_ptr(charset).to_str().unwrap().as_bytes(),
|
|
||||||
) {
|
|
||||||
let data = std::slice::from_raw_parts(
|
let data = std::slice::from_raw_parts(
|
||||||
decoded_data as *const u8,
|
decoded_data as *const u8,
|
||||||
decoded_data_bytes,
|
decoded_data_bytes,
|
||||||
@@ -655,12 +654,9 @@ impl<'a> MimeParser<'a> {
|
|||||||
}
|
}
|
||||||
if ok_to_continue {
|
if ok_to_continue {
|
||||||
/* check header directly as is_send_by_messenger is not yet set up */
|
/* check header directly as is_send_by_messenger is not yet set up */
|
||||||
let is_msgrmsg =
|
let is_msgrmsg = self.lookup_optional_field("Chat-Version").is_some();
|
||||||
self.lookup_optional_field("Chat-Version").is_some();
|
|
||||||
|
|
||||||
let simplified_txt = if decoded_data_bytes <= 0
|
let simplified_txt = if decoded_data_bytes <= 0 || decoded_data.is_null() {
|
||||||
|| decoded_data.is_null()
|
|
||||||
{
|
|
||||||
"".into()
|
"".into()
|
||||||
} else {
|
} else {
|
||||||
let input_c = strndup(decoded_data, decoded_data_bytes as _);
|
let input_c = strndup(decoded_data, decoded_data_bytes as _);
|
||||||
@@ -676,10 +672,7 @@ impl<'a> MimeParser<'a> {
|
|||||||
part.mimetype = mime_type;
|
part.mimetype = mime_type;
|
||||||
part.msg = Some(simplified_txt);
|
part.msg = Some(simplified_txt);
|
||||||
part.msg_raw = {
|
part.msg_raw = {
|
||||||
let raw_c = strndup(
|
let raw_c = strndup(decoded_data, decoded_data_bytes as libc::c_ulong);
|
||||||
decoded_data,
|
|
||||||
decoded_data_bytes as libc::c_ulong,
|
|
||||||
);
|
|
||||||
let raw = to_string_lossy(raw_c);
|
let raw = to_string_lossy(raw_c);
|
||||||
free(raw_c.cast());
|
free(raw_c.cast());
|
||||||
Some(raw)
|
Some(raw)
|
||||||
@@ -706,8 +699,7 @@ impl<'a> MimeParser<'a> {
|
|||||||
for cur1 in (*(*(*mime).mm_mime_fields).fld_list).into_iter() {
|
for cur1 in (*(*(*mime).mm_mime_fields).fld_list).into_iter() {
|
||||||
let field = cur1 as *mut mailmime_field;
|
let field = cur1 as *mut mailmime_field;
|
||||||
if !field.is_null()
|
if !field.is_null()
|
||||||
&& (*field).fld_type
|
&& (*field).fld_type == MAILMIME_FIELD_DISPOSITION as libc::c_int
|
||||||
== MAILMIME_FIELD_DISPOSITION as libc::c_int
|
|
||||||
&& !(*field).fld_data.fld_disposition.is_null()
|
&& !(*field).fld_data.fld_disposition.is_null()
|
||||||
{
|
{
|
||||||
let file_disposition: *mut mailmime_disposition =
|
let file_disposition: *mut mailmime_disposition =
|
||||||
@@ -717,35 +709,26 @@ impl<'a> MimeParser<'a> {
|
|||||||
let dsp_param = cur2 as *mut mailmime_disposition_parm;
|
let dsp_param = cur2 as *mut mailmime_disposition_parm;
|
||||||
if !dsp_param.is_null() {
|
if !dsp_param.is_null() {
|
||||||
if (*dsp_param).pa_type
|
if (*dsp_param).pa_type
|
||||||
== MAILMIME_DISPOSITION_PARM_PARAMETER
|
== MAILMIME_DISPOSITION_PARM_PARAMETER as libc::c_int
|
||||||
as libc::c_int
|
|
||||||
&& !(*dsp_param).pa_data.pa_parameter.is_null()
|
&& !(*dsp_param).pa_data.pa_parameter.is_null()
|
||||||
&& !(*(*dsp_param).pa_data.pa_parameter)
|
&& !(*(*dsp_param).pa_data.pa_parameter).pa_name.is_null()
|
||||||
.pa_name
|
|
||||||
.is_null()
|
|
||||||
&& strncmp(
|
&& strncmp(
|
||||||
(*(*dsp_param).pa_data.pa_parameter)
|
(*(*dsp_param).pa_data.pa_parameter).pa_name,
|
||||||
.pa_name,
|
b"filename*\x00" as *const u8 as *const libc::c_char,
|
||||||
b"filename*\x00" as *const u8
|
|
||||||
as *const libc::c_char,
|
|
||||||
9,
|
9,
|
||||||
) == 0i32
|
) == 0i32
|
||||||
{
|
{
|
||||||
// we assume the filename*?* parts are in order, not seen anything else yet
|
// we assume the filename*?* parts are in order, not seen anything else yet
|
||||||
filename_parts += &to_string_lossy(
|
filename_parts += &to_string_lossy(
|
||||||
(*(*dsp_param).pa_data.pa_parameter)
|
(*(*dsp_param).pa_data.pa_parameter).pa_value,
|
||||||
.pa_value,
|
|
||||||
);
|
);
|
||||||
} else if (*dsp_param).pa_type
|
} else if (*dsp_param).pa_type
|
||||||
== MAILMIME_DISPOSITION_PARM_FILENAME
|
== MAILMIME_DISPOSITION_PARM_FILENAME as libc::c_int
|
||||||
as libc::c_int
|
|
||||||
{
|
{
|
||||||
// might be a wrongly encoded filename
|
// might be a wrongly encoded filename
|
||||||
let s = to_string_lossy((*dsp_param).pa_data.pa_filename);
|
let s = to_string_lossy((*dsp_param).pa_data.pa_filename);
|
||||||
// this is used only if the parts buffer stays empty
|
// this is used only if the parts buffer stays empty
|
||||||
desired_filename = dc_decode_header_words_safe(
|
desired_filename = dc_decode_header_words_safe(&s)
|
||||||
&s
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -754,8 +737,7 @@ impl<'a> MimeParser<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !filename_parts.is_empty() {
|
if !filename_parts.is_empty() {
|
||||||
desired_filename =
|
desired_filename = dc_decode_ext_header(filename_parts.as_bytes()).into_owned();
|
||||||
dc_decode_ext_header(filename_parts.as_bytes()).into_owned();
|
|
||||||
}
|
}
|
||||||
if desired_filename.is_empty() {
|
if desired_filename.is_empty() {
|
||||||
let param = mailmime_find_ct_parameter(mime, "name");
|
let param = mailmime_find_ct_parameter(mime, "name");
|
||||||
@@ -772,35 +754,27 @@ impl<'a> MimeParser<'a> {
|
|||||||
if !(*mime).mm_content_type.is_null()
|
if !(*mime).mm_content_type.is_null()
|
||||||
&& !(*(*mime).mm_content_type).ct_subtype.is_null()
|
&& !(*(*mime).mm_content_type).ct_subtype.is_null()
|
||||||
{
|
{
|
||||||
desired_filename = format!(
|
desired_filename =
|
||||||
"file.{}",
|
format!("file.{}", as_str((*(*mime).mm_content_type).ct_subtype));
|
||||||
as_str((*(*mime).mm_content_type).ct_subtype)
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
ok_to_continue = false;
|
ok_to_continue = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ok_to_continue {
|
if ok_to_continue {
|
||||||
if desired_filename.starts_with("location")
|
if desired_filename.starts_with("location")
|
||||||
&& desired_filename.ends_with(".kml") {
|
&& desired_filename.ends_with(".kml")
|
||||||
|
{
|
||||||
if !decoded_data.is_null() && decoded_data_bytes > 0 {
|
if !decoded_data.is_null() && decoded_data_bytes > 0 {
|
||||||
let d = dc_null_terminate(
|
let d = dc_null_terminate(decoded_data, decoded_data_bytes as i32);
|
||||||
decoded_data,
|
self.location_kml = location::Kml::parse(self.context, as_str(d)).ok();
|
||||||
decoded_data_bytes as i32,
|
|
||||||
);
|
|
||||||
self.location_kml =
|
|
||||||
location::Kml::parse(self.context, as_str(d)).ok();
|
|
||||||
free(d.cast());
|
free(d.cast());
|
||||||
}
|
}
|
||||||
} else if desired_filename.starts_with("message")
|
} else if desired_filename.starts_with("message")
|
||||||
&& desired_filename.ends_with(".kml") {
|
&& desired_filename.ends_with(".kml")
|
||||||
|
{
|
||||||
if !decoded_data.is_null() && decoded_data_bytes > 0 {
|
if !decoded_data.is_null() && decoded_data_bytes > 0 {
|
||||||
let d = dc_null_terminate(
|
let d = dc_null_terminate(decoded_data, decoded_data_bytes as i32);
|
||||||
decoded_data,
|
self.message_kml = location::Kml::parse(self.context, as_str(d)).ok();
|
||||||
decoded_data_bytes as i32,
|
|
||||||
);
|
|
||||||
self.message_kml =
|
|
||||||
location::Kml::parse(self.context, as_str(d)).ok();
|
|
||||||
free(d.cast());
|
free(d.cast());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -835,8 +809,7 @@ impl<'a> MimeParser<'a> {
|
|||||||
desired_filename: &str,
|
desired_filename: &str,
|
||||||
) {
|
) {
|
||||||
/* create a free file name to use */
|
/* create a free file name to use */
|
||||||
let path_filename =
|
let path_filename = dc_get_fine_path_filename(self.context, "$BLOBDIR", desired_filename);
|
||||||
dc_get_fine_path_filename(self.context, "$BLOBDIR", desired_filename);
|
|
||||||
let bytes = std::slice::from_raw_parts(decoded_data as *const u8, decoded_data_bytes);
|
let bytes = std::slice::from_raw_parts(decoded_data as *const u8, decoded_data_bytes);
|
||||||
|
|
||||||
/* copy data to file */
|
/* copy data to file */
|
||||||
|
|||||||
Reference in New Issue
Block a user