From 642a3f85ef262f5d21f80e4c95697482ec6fe1c8 Mon Sep 17 00:00:00 2001 From: Karol Kosek Date: Sun, 3 Sep 2023 00:31:07 +0200 Subject: [PATCH] LibIMAP: Parse body-type-msg to spec --- Userland/Libraries/LibIMAP/Objects.h | 2 +- Userland/Libraries/LibIMAP/Parser.cpp | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibIMAP/Objects.h b/Userland/Libraries/LibIMAP/Objects.h index 00549afd93..7bb5a8087b 100644 --- a/Userland/Libraries/LibIMAP/Objects.h +++ b/Userland/Libraries/LibIMAP/Objects.h @@ -213,7 +213,7 @@ struct BodyStructureData { HashMap fields; unsigned bytes { 0 }; unsigned lines { 0 }; - Optional envelope; + Optional>> contanied_message; Optional md5 {}; Optional>> disposition {}; diff --git a/Userland/Libraries/LibIMAP/Parser.cpp b/Userland/Libraries/LibIMAP/Parser.cpp index 63a3ff8373..ae17ee70cf 100644 --- a/Userland/Libraries/LibIMAP/Parser.cpp +++ b/Userland/Libraries/LibIMAP/Parser.cpp @@ -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(move(body)) }; + + consume(" "sv); + data.lines = MUST(parse_number()); } else { // body-type-basic // NOTE: "media-basic SP body-fields" is already parsed.