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,27 +584,48 @@ fn build_imap_email_struct<'a>(
|
||||||
extension_data: None,
|
extension_data: None,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
MessageStructure::MultiPart((id, l)) => {
|
MessageStructure::MultiPart((id, lp)) => {
|
||||||
todo!()
|
let part = msg
|
||||||
/*let part = msg.parts.get(id)?;
|
.parts
|
||||||
let mp = match part {
|
.get(*id)
|
||||||
MessagePart::Multipart(mp) => mp,
|
.map(|p| match p {
|
||||||
_ => unreachable!("Only a MessagePart part entry is allowed here.");
|
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 {
|
Ok(BodyStructure::Multi {
|
||||||
bodies: l.map(|inner_node| build_email_struct(msg, inner_node)),
|
bodies: lp
|
||||||
subtype: "",
|
.iter()
|
||||||
extension_data: Some(MultipartExtensionData {
|
.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![],
|
parameter_list: vec![],
|
||||||
disposition: None,
|
disposition: None,
|
||||||
language: None,
|
language: None,
|
||||||
location: None,
|
location: None,
|
||||||
extension: vec![],
|
extension: vec![],
|
||||||
})
|
})*/
|
||||||
}
|
})
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -715,7 +736,7 @@ mod tests {
|
||||||
use imap_codec::codec::Encode;
|
use imap_codec::codec::Encode;
|
||||||
use std::fs;
|
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
|
/// so this test might allow invalid results. But at least it allows us to quickly test a
|
||||||
/// large variety of emails.
|
/// large variety of emails.
|
||||||
/// Keep in mind that special cases must still be tested manually!
|
/// Keep in mind that special cases must still be tested manually!
|
||||||
|
@ -724,6 +745,7 @@ mod tests {
|
||||||
let prefixes = [
|
let prefixes = [
|
||||||
"tests/emails/dxflrs/0001_simple",
|
"tests/emails/dxflrs/0001_simple",
|
||||||
"tests/emails/dxflrs/0002_mime",
|
"tests/emails/dxflrs/0002_mime",
|
||||||
|
"tests/emails/dxflrs/0003_mime-in-mime",
|
||||||
];
|
];
|
||||||
|
|
||||||
for pref in prefixes.iter() {
|
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"
|
Content-Type: text/plain; charset="us-ascii"
|
||||||
|
|
||||||
Hello 1
|
Hello 1
|
||||||
|
|
||||||
--child
|
--child
|
||||||
Content-Type: text/plain; charset="us-ascii"
|
Content-Type: text/plain; charset="us-ascii"
|
||||||
|
|
||||||
Hello 2
|
Hello 2
|
||||||
|
|
||||||
--child--
|
--child--
|
||||||
|
--parent
|
||||||
|
Content-Type: text/plain; charset="us-ascii"
|
||||||
|
|
||||||
|
Hello 3
|
||||||
|
|
||||||
--parent--
|
--parent--
|
||||||
|
|
|
@ -9,3 +9,5 @@ From: Garage team <garagehq@deuxfleurs.fr>
|
||||||
Subject: Welcome to Aerogramme!!
|
Subject: Welcome to Aerogramme!!
|
||||||
|
|
||||||
This is just a test email, feel free to ignore.
|
This is just a test email, feel free to ignore.
|
||||||
|
|
||||||
|
--delim--
|
||||||
|
|
Loading…
Reference in a new issue