LibIMAP: Parse body-type-msg to spec

This commit is contained in:
Karol Kosek 2023-09-03 00:31:07 +02:00 committed by Andrew Kaster
parent 4a92d712ea
commit 642a3f85ef
Notes: sideshowbarker 2024-07-17 07:08:37 +09:00
2 changed files with 10 additions and 3 deletions

View File

@ -213,7 +213,7 @@ struct BodyStructureData {
HashMap<DeprecatedString, DeprecatedString> fields;
unsigned bytes { 0 };
unsigned lines { 0 };
Optional<Envelope> envelope;
Optional<Tuple<Envelope, NonnullOwnPtr<BodyStructure>>> contanied_message;
Optional<DeprecatedString> md5 {};
Optional<Tuple<DeprecatedString, HashMap<DeprecatedString, DeprecatedString>>> disposition {};

View File

@ -453,11 +453,18 @@ BodyStructure Parser::parse_one_part_body()
// NOTE: "media-text SP body-fields" part is already parsed.
consume(" "sv);
data.lines = MUST(parse_number());
} else if (data.type.equals_ignoring_ascii_case("MESSAGE"sv) && data.subtype.equals_ignoring_ascii_case("RFC822"sv)) {
} else if (data.type.equals_ignoring_ascii_case("MESSAGE"sv) && data.subtype.is_one_of_ignoring_ascii_case("RFC822"sv, "GLOBAL"sv)) {
// body-type-msg
// NOTE: "media-message SP body-fields" part is already parsed.
consume(" "sv);
data.envelope = parse_envelope();
auto envelope = parse_envelope();
consume(" ("sv);
auto body = parse_body_structure();
data.contanied_message = Tuple { move(envelope), make<BodyStructure>(move(body)) };
consume(" "sv);
data.lines = MUST(parse_number());
} else {
// body-type-basic
// NOTE: "media-basic SP body-fields" is already parsed.