libpEpMIME/ParsingHeuristics

MIME structure mapping as Heuristics

This is an algorithm to map a MIME tree structure into struct _message of pEp. Goals are:

  1. Correctly encoded MIME must be recognized correctly
  2. Common mistakenly encoded MIME must be recognized correctly
  3. For all uncommon cases there must be a good hit rate in recognition, at least good fallback solutions

Rules:

  1. MIME leaves with “Content-Disposition: attachment” are always attachments. All other are considered as “inline”.
  2. “multipart/*" is parsed recursively up to a compile-time configurable recursion limit (default: 100)

  3. The first inline text/plain leaf delivers .longmsg; in case there is none .longmsg keeps being empty.
  4. The first inline text/html leaf delivers .longmsg_formatted; in case there is none .longmsg_formatted keeps being empty.
  5. All other leaves deliver attachments, with their “disposition” field set as defined above.