Ver Fonte

LibIMAP: Parse body-type-msg to spec

Karol Kosek há 1 ano atrás
pai
commit
642a3f85ef

+ 1 - 1
Userland/Libraries/LibIMAP/Objects.h

@@ -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 {};

+ 9 - 2
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<BodyStructure>(move(body)) };
+
+        consume(" "sv);
+        data.lines = MUST(parse_number());
     } else {
         // body-type-basic
         // NOTE: "media-basic SP body-fields" is already parsed.