WIP mime headers

This commit is contained in:
Quentin 2023-07-03 11:40:02 +02:00
parent 541c92f088
commit d64b7a0bbc
Signed by: quentin
GPG key ID: E9602264D639FF68
3 changed files with 24 additions and 0 deletions

View file

@ -97,6 +97,7 @@ Todo:
| 🔴 |2047 | ↳ MIME (Multipurpose Internet Mail Extensions) Part Three: Message Header Extensions for Non-ASCII Text |
| 🔴 |2048 | ↳ Multipurpose Internet Mail Extensions (MIME) Part Four: Registration Procedures |
| 🔴 |2049 | ↳ Multipurpose Internet Mail Extensions (MIME) Part Five: Conformance Criteria and Examples |
| 🔴 |2183 | Communicating Presentation Information in Internet Messages: The Content-Disposition Header Field |
| 🟩 |6532 | Internationalized Email Headers |
| 🔴 |9228 | Delivered-To Email Header Field |

View file

@ -65,6 +65,7 @@ impl<'a> TryFrom<&'a Lazy<'a>> for Field<'a> {
Lazy::ReturnPath(v) => v.try_into().map(|v| ReturnPath(v)),
Lazy::Optional(k, v) => v.try_into().map(|v| Optional(k, v)),
Lazy::Rescue(v) => Ok(Rescue(v)),
_ => todo!(),
}
}
}

View file

@ -40,6 +40,15 @@ pub struct ReceivedLog<'a>(pub &'a str);
#[derive(Debug, PartialEq)]
pub struct Path<'a>(pub &'a str);
#[derive(Debug, PartialEq)]
pub struct Version<'a>(pub &'a str);
#[derive(Debug, PartialEq)]
pub struct Type<'a>(pub &'a str);
#[derive(Debug, PartialEq)]
pub struct Mechanism<'a>(pub &'a str);
#[derive(Debug, PartialEq)]
pub enum Field<'a> {
// 3.6.1. The Origination Date Field
@ -70,6 +79,13 @@ pub enum Field<'a> {
Received(ReceivedLog<'a>),
ReturnPath(Mailbox<'a>),
// MIME RFC 2045
MIMEVersion(Version<'a>),
ContentType(Type<'a>),
ContentTransferEncoding(Mechanism<'a>),
ContentID(Identifier<'a>),
ContentDescription(Unstructured<'a>),
// 3.6.8. Optional Fields
Optional(&'a str, Unstructured<'a>),
@ -128,6 +144,12 @@ fn correct_field(input: &str) -> IResult<&str, Field> {
"return-path" => ReturnPath(Mailbox(rest)),
"received" => Received(ReceivedLog(rest)),
"mime-version" => MIMEVersion(Version(rest)),
"content-type" => ContentType(Type(rest)),
"content-transfer-encoding" => ContentTransferEncoding(Mechanism(rest)),
"content-id" => ContentID(Identifier(rest)),
"content-description" => ContentDescription(Unstructured(rest)),
_ => Optional(name, Unstructured(rest)),
},
)