Eike Kettner created MAILBOX-187:
------------------------------------

             Summary: Parsing bugs MaildirMessageName?
                 Key: MAILBOX-187
                 URL: https://issues.apache.org/jira/browse/MAILBOX-187
             Project: James Mailbox
          Issue Type: Bug
          Components: maildir
            Reporter: Eike Kettner


I'm trying to migrate my postfix+courier setup to apache james. I want to keep 
my maildirs and so pointed james to my courier maildir folders. When connecting 
to the mailbox, james threw `StringIndexArrayOutOfBoundsEx` and `NullPointerEx` 
at me.

The NPE came out of the class `MailderMessage`, while the IndexOutOfBounds were 
coming from `MaildirMessageName`. All those exceptions were caused by the 
filenames in my mailbox, that were not as expected by the parser. Looking at 
the source, I found that while parsing a `MaildirMessageName`, the size field 
is expected to be present. If not, parsing fails. I even have files in my 
mailbox without neither attributes nor flags in the filename... This would also 
cause the parser to fail.

The NPE in `MaildirMessage` was due to a message without flags while setting 
the RECENT flag in the constructor. There is another subtle potential NPE bug 
in `MaildirMessage` when returning the size obtained from the 
`MaildirMessageName` object. This could return null which would fail when 
casting to a primitive long. Since the parser expects the size to be present, 
this does not occur right now.

While I'm fine with renaming my files to satisfy the `MaildirMessageName` 
parser, I thought that it is better, if the parser would be more lenient 
regarding the message filename. I also skimmed though this page 
http://cr.yp.to/proto/maildir.html and couldn't find a hint that fields and 
flags is a requirement of a message filename? But I'm very new to those 
subjects and there may be another specification or I failed to understand. 
Well, at the end, it would be great if the parser accepts my message filenames, 
too :-). I'll attach a patch that aims to fix those things (including a unit 
test), if you agree. 

Thanks for such a great project, by the way!

Kind Regards, Eike

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to