Add support for mime in mime
This commit is contained in:
parent
2f51128467
commit
cba06269ab
5 changed files with 48 additions and 17 deletions
|
@ -584,28 +584,49 @@ fn build_imap_email_struct<'a>(
|
|||
extension_data: None,
|
||||
})
|
||||
}
|
||||
MessageStructure::MultiPart((id, l)) => {
|
||||
todo!()
|
||||
/*let part = msg.parts.get(id)?;
|
||||
let mp = match part {
|
||||
MessagePart::Multipart(mp) => mp,
|
||||
_ => unreachable!("Only a MessagePart part entry is allowed here.");
|
||||
}
|
||||
MessageStructure::MultiPart((id, lp)) => {
|
||||
let part = msg
|
||||
.parts
|
||||
.get(*id)
|
||||
.map(|p| match p {
|
||||
MessagePart::Multipart(mp) => Some(mp),
|
||||
_ => None,
|
||||
})
|
||||
.flatten()
|
||||
.ok_or(anyhow!(
|
||||
"Email part referenced in email structure is missing"
|
||||
))?;
|
||||
|
||||
let subtype = IString::try_from(
|
||||
part.headers_rfc
|
||||
.get(&RfcHeader::ContentType)
|
||||
.ok_or(anyhow!("Content-Type is missing but required here."))?
|
||||
.get_content_type()
|
||||
.c_subtype
|
||||
.as_ref()
|
||||
.ok_or(anyhow!("Content-Type invalid, missing subtype"))?
|
||||
.to_string(),
|
||||
)
|
||||
.map_err(|_| {
|
||||
anyhow!("Unable to build IString from given Content-Type subtype given")
|
||||
})?;
|
||||
|
||||
BodyStructure::Multi {
|
||||
bodies: l.map(|inner_node| build_email_struct(msg, inner_node)),
|
||||
subtype: "",
|
||||
extension_data: Some(MultipartExtensionData {
|
||||
Ok(BodyStructure::Multi {
|
||||
bodies: lp
|
||||
.iter()
|
||||
.map(|inner_node| build_imap_email_struct(msg, inner_node))
|
||||
.fold(Ok(vec![]), try_collect_shime)?,
|
||||
subtype,
|
||||
extension_data: None,
|
||||
/*Some(MultipartExtensionData {
|
||||
parameter_list: vec![],
|
||||
disposition: None,
|
||||
language: None,
|
||||
location: None,
|
||||
extension: vec![],
|
||||
})*/
|
||||
})
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -715,7 +736,7 @@ mod tests {
|
|||
use imap_codec::codec::Encode;
|
||||
use std::fs;
|
||||
|
||||
/// Future automated test. We use lossy utf8 conversion + lowercasing everything,
|
||||
/// Future automated test. We use lossy utf8 conversion + lowercase everything,
|
||||
/// so this test might allow invalid results. But at least it allows us to quickly test a
|
||||
/// large variety of emails.
|
||||
/// Keep in mind that special cases must still be tested manually!
|
||||
|
@ -724,6 +745,7 @@ mod tests {
|
|||
let prefixes = [
|
||||
"tests/emails/dxflrs/0001_simple",
|
||||
"tests/emails/dxflrs/0002_mime",
|
||||
"tests/emails/dxflrs/0003_mime-in-mime",
|
||||
];
|
||||
|
||||
for pref in prefixes.iter() {
|
||||
|
|
|
@ -1 +1 @@
|
|||
(BODY ((("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 7 0)("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 7 0) "mixed") "mixed"))
|
||||
(BODY ((("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 9 1)("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 9 1) "mixed")("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 9 1) "mixed"))
|
|
@ -1 +1 @@
|
|||
(BODYSTRUCTURE ((("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 7 0 NIL NIL NIL NIL)("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 7 0 NIL NIL NIL NIL) "mixed" ("boundary" "child") NIL NIL NIL) "mixed" ("boundary" "parent") NIL NIL NIL))
|
||||
(BODYSTRUCTURE ((("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 9 1 NIL NIL NIL NIL)("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 9 1 NIL NIL NIL NIL) "mixed" ("boundary" "child") NIL NIL NIL)("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 9 1 NIL NIL NIL NIL) "mixed" ("boundary" "parent") NIL NIL NIL))
|
|
@ -9,9 +9,16 @@ Content-Type: multipart/mixed; boundary="child";
|
|||
Content-Type: text/plain; charset="us-ascii"
|
||||
|
||||
Hello 1
|
||||
|
||||
--child
|
||||
Content-Type: text/plain; charset="us-ascii"
|
||||
|
||||
Hello 2
|
||||
|
||||
--child--
|
||||
--parent
|
||||
Content-Type: text/plain; charset="us-ascii"
|
||||
|
||||
Hello 3
|
||||
|
||||
--parent--
|
||||
|
|
|
@ -9,3 +9,5 @@ From: Garage team <garagehq@deuxfleurs.fr>
|
|||
Subject: Welcome to Aerogramme!!
|
||||
|
||||
This is just a test email, feel free to ignore.
|
||||
|
||||
--delim--
|
||||
|
|
Loading…
Reference in a new issue