Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Several BODY[...] sections are parsed incorreclty #66

Open
lpld opened this issue Jan 6, 2021 · 0 comments
Open

Several BODY[...] sections are parsed incorreclty #66

lpld opened this issue Jan 6, 2021 · 0 comments

Comments

@lpld
Copy link

lpld commented Jan 6, 2021

I'm trying to load a message with BODY[TEXT] and BODY[HEADER]:

imapClient.uidfetch(
   Set.of(106),
   FetchDataItemType.UID,
   new BodyPeekFetchDataItem("TEXT"),
   new BodyPeekFetchDataItem("HEADER")
)

According to the trace logs, everything is fine:

2021-01-06 17:44:29,651 [info] c.h.i.c.I.unknown-client - SEND: A002 UID FETCH 106 (BODY.PEEK[TEXT] BODY.PEEK[HEADER] UID)
...
2021-01-06 17:44:30,345 [info] c.h.i.p.R.unknown-client - RCV(FETCH): (UID 106 BODY[TEXT] {4043}
...
2021-01-06 17:44:30,347 [info] c.h.i.p.R.unknown-client - RCV(FETCH):  BODY[HEADER]
...

Not posting the whole log, because it's quite huge, but it's clear that the server returns both BODY[TEXT] and BODY[HEADER] sections.

However, the resulting ImapMessage object doesn't include text body. getBody returns org.apache.james.mime4j.dom.Multipart with 0 parts.

I debugged the code a bit. Looks like each of the sections is parsed separately, and then the "header" section overwrites the "text" section in the resulting ImapMessage. If I don't query header, there's no issue - the body contains the text.

I don't know if this can be fixed somehow with current ImapMessage implementation. It has only one body property, and it's not clear how to combine all the sections into a single org.apache.james.mime4j.dom.Message, but current behavior definitely looks wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant