Home GnuPG
Diffusion GpgOL c0ca4f1b254f

Add support for encapsulated message/rfc822 data

Description

Add support for encapsulated message/rfc822 data

* src/attachment.cpp (Attachment::set_is_mime, Attachment::is_mime):
New. Mark if the attachment contains parsable MIME data.
(Attachment::attach_to): Moved out from mail.cpp to Attachment class
and added handling for is_mime.
* src/attachment.h: Update accordingly.
* src/mail.cpp (Mail::add_atttachments_o): Use Attachment::attach_to
instead of doing it here.
* src/mimedataprovider.cpp (mime_context): Extend with
  in_encapsulated_msg state.
(t2body): Mark message/rfc822 content-types in subparts as
encapsulated.
(MimeDataProvider::collect_input_lines): Handle in_encapsulated_msg
state.
(MimeDataProvider::get_header): Add to class and not just static.
(MimeDataProvider::finalize): Update call to get_header.
* src/mimedataprovider.h (MimeDataProvider::get_header): Declare.
* src/rfc822parse.c (rfc822parse_query_boundary): New. Expose
boundary.
* src/rfc822parse.h (rfc822parse_query_boundary): Declare.

When we detect a nested mimepart with content-type message/rfc822
we now skip the first line, as usual, then collect the data that
follows into an attachment without passing the data to rfc822parse.
This is done to ensure that the parser is not confused by e.g. multiple
headers from the encapsulated mail.

In collect_input_lines we search "manually" for the boundary of the
encapsulated message part and if found finish the part in rfc822_parse
and continue.

The Attachment is then marked as containing MIME data with the new
is_mime flag. And if that flag is set the filename and displayname
are extracted from the subject of the encapsulated mail, if possible.
This is done in Attachment::add_to where the data of the attachment
is placed into a new MimeDataProvider which now provides easy access
to the headers.

Details

Provenance
aheineckeAuthored on Aug 23 2024, 12:28 PM
Parents
rOdbcfa2b2f8bd: Add filename sanitizers for windows filenames
Branches
Unknown
Tags
Unknown
Tasks
T7266: GpgOL: Add handling for content type message/rfc822