Browse Source

Pass attachment names through decoding

Attachment names in Content-Type parameters can be encoded (eg
=?UTF-8...), so try decoding with phrase() first
tags/pre-alpha-0.3.2
Manos Pitsidianakis 5 months ago
parent
commit
250129665b
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS. GPG Key ID: 73627C2F690DF710
2 changed files with 12 additions and 7 deletions
  1. +1
    -1
      melib/src/email/parser.rs
  2. +11
    -6
      ui/src/components/mail/view.rs

+ 1
- 1
melib/src/email/parser.rs View File

@@ -787,6 +787,7 @@ named_args!(pub parts<'a>(boundary: &'a [u8]) < Vec<&'this_is_probably_unique_i_
( { Vec::<&[u8]>::new() } ))
));

/* Caution: values should be passed through phrase() */
named!(
content_type_parameter<(&[u8], &[u8])>,
do_parse!(
@@ -1190,5 +1191,4 @@ mod tests {
}
}
}

}

+ 11
- 6
ui/src/components/mail/view.rs View File

@@ -875,13 +875,18 @@ impl Component for MailView {
ContentType::Other { ref name, .. } => {
let attachment_type = u.mime_type();
let binary = query_default_app(&attachment_type);
let mut name_opt = name.as_ref().and_then(|n| {
melib::email::parser::phrase(n.as_bytes())
.to_full_result()
.ok()
.and_then(|n| String::from_utf8(n).ok())
});
if name_opt.is_none() {
name_opt = name.as_ref().map(|n| n.clone());
}
if let Ok(binary) = binary {
let p = create_temp_file(
&decode(u, None),
name.as_ref().map(|n| n.clone()),
None,
true,
);
let p =
create_temp_file(&decode(u, None), name_opt, None, true);
Command::new(&binary)
.arg(p.path())
.stdin(Stdio::piped())


Loading…
Cancel
Save