Opened 9 years ago

#6281 enhancement new

Try to simplify the BODY handling in mail.imap4.IMAP4Client._parseFetchPairs

Reported by: Jean-Paul Calderone Owned by:
Priority: normal Milestone:
Component: mail Keywords:
Cc: Branch:
Author:

Description

_parseFetchPairs works really hard to figure out what data it is being handed. No small part of this work is due to the fact that the different forms of the BODY response are represented in very different ways. I'll reproduce the comment in _parseFetchPairs on this topic:

# The parsed forms of responses like:
#
# BODY[] VALUE
# BODY[TEXT] VALUE
# BODY[HEADER.FIELDS (SUBJECT)] VALUE
# BODY[HEADER.FIELDS (SUBJECT)]<N.M> VALUE
#
# are:
#
# ["BODY", [], VALUE]
# ["BODY", ["TEXT"], VALUE]
# ["BODY", ["HEADER.FIELDS", ["SUBJECT"]], VALUE]
# ["BODY", ["HEADER.FIELDS", ["SUBJECT"]], "<N.M>", VALUE]
#
# Additionally, BODY responses for multipart messages are
# represented as:
#
#    ["BODY", VALUE]
#
# with list as the type of VALUE and the type of VALUE[0].

The function currently tries to recognize these (and perhaps other?) of these patterns in order to find the correct VALUE (it also bundles up a bunch of the extra list elements along with "BODY" to form the key, so applications have an easier time determining what data they've actually gotten).

One approach that might make things easier is if the parser which produces this list of things could keep BODY together with TEXT or HEADER.FIELDS or what every the rest of the "key" is.

Change History (0)

Note: See TracTickets for help on using tickets.