Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

IMAP Envelope parsing problems

843830Jun 15 2005 — edited Jun 15 2005
Hi,

I've hit a problem where a message on my imap server (courier-imap 2.2.1) is causing an exception while reading the envelope. This is using javamail 1.3.2 and 1.3.3ea. The envelope response that the server returns looks invalid and is as follows.

A5 FETCH 1272 (ENVELOPE INTERNALDATE RFC822.SIZE)
* 1272 FETCH (ENVELOPE (NIL "SPAMIS:" ((NIL NIL "SPAMIS" NIL)) ((NIL NIL "SPAMIS" NIL)) ((NIL NIL "SPAMIS" NIL)) ((NIL NIL "tom" "uwillsee.com")) NIL NIL NIL "<119307.G027@spamis.org>") INTERNALDATE "02-Jun-2005 16:01:59 -0400" RFC822.SIZE 10936)

Thats the command followed by the response. The message is obviously spam which was sent to my address. Anyway the address (NIL NIL "SPAMIS" NIL) seems to cause the problem as the host part (last NIL entry) is NIL, the parser assumes it is a group and the group parsing then fails which causes the entire envelope to fail.

I submitted this as a bug and got an internal review ID of: 468775. I've since downloaded the source of javamail-1.3.2 and created the following patch which seems to fix the problem for me. I've no way of updating the bug yet, so I'm attaching the patch here.

*** ORIG_ENVELOPE.java 2005-06-15 17:30:28.497540792 +0900
--- share/classes/com/sun/mail/imap/protocol/ENVELOPE.java 2005-06-15 18:02:19.888965128 +0900
*************** class IMAPAddress extends InternetAddres
*** 125,131 ****
if (r.readByte() != ')') // skip past terminating ')'
throw new ParsingException("ADDRESS parse error");

! if (host == null) {
// it's a group list, start or end
group = true;
groupname = mb;
--- 125,132 ----
if (r.readByte() != ')') // skip past terminating ')'
throw new ParsingException("ADDRESS parse error");

! // if next byte is ) its the end of the address and not a group.
! if (host == null && r.peekByte() != ')') {
// it's a group list, start or end
group = true;
groupname = mb;


Best regards,

Tom.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 13 2005
Added on Jun 15 2005
2 comments
563 views