Uploaded image for project: 'James Server'
  1. James Server
  2. JAMES-328

TOP <msg> 0 does not return a terminator on error

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.2.0
    • Fix Version/s: 2.3.0
    • Component/s: POP3Server
    • Labels:
      None
    • Environment:
      James version 2.2.0 running on redhat 9, java version 1.4.2_03, mysql version 4.0.17 pc-linux-686

      Description

      I first noticed the problem using Java mail version 1.3.1 attempting to retrieve a malformed pop3 message from James. The message headers specify an invalid encoding type "Content-Transfer-Encoding: plain". When the command "TOP <msg> 0" is issued, James returns "+OK Message follows", then successfully returns all headers. Upon attempting to retrieve 0 lines of the message, it apparently encounters an error with that invalid encoding type and returns "-ERR Error while retrieving message." rather then the termination character of carriage return, period, carriage return. Javamail chokes on this waiting for the period termination character as it thinks that the "-ERR" text is a valid part of the message.

      The "RETR" command works properly however and returns the message without error. Looking into the source code for James, I found that even though the argument is to return 0 lines of the message, James still attempts to write the message to the output with the call "mc.writeContentTo(nouts, lines);" lines = 0 in this case and I put in a temporary work around to not do this unless lines was > 0, but if a TOP command was issued with 5 for example, it would still return the invalid response.

      Not sure what the best solution is, but it needs to either return -ERR up front, or to return the termination character regardless so that dumb mail clients can process it.

      1. top.diff
        2 kB
        Hes Siemelink

        Activity

        Hide
        hes.siemelink Hes Siemelink added a comment -

        Here's a proposed quick-fix that at least sends the terminating 'dot' if an error occurs.

        Show
        hes.siemelink Hes Siemelink added a comment - Here's a proposed quick-fix that at least sends the terminating 'dot' if an error occurs.
        Hide
        bago Stefano Bagnara added a comment -

        Here is the exception that is thrown:

        java.io.IOException: Unknown encoding: plain
        at javax.mail.internet.MimePartDataSource.getInputStream(MimePartDataSource.java:82)
        at javax.activation.DataHandler.getInputStream(DataHandler.java:220)
        at javax.mail.internet.MimeMessage.getInputStream(MimeMessage.java:1242)
        at org.apache.james.core.MimeMessageWrapper.getInputStream(MimeMessageWrapper.java:652)
        at org.apache.james.core.MailImpl.writeContentTo(MailImpl.java:500)
        at org.apache.james.pop3server.POP3Handler.doTOP(POP3Handler.java:976)
        at org.apache.james.pop3server.POP3Handler.parseCommand(POP3Handler.java:491)
        at org.apache.james.pop3server.POP3Handler.handleConnection(POP3Handler.java:273)
        at org.apache.james.util.connection.ServerConnection$ClientConnectionRunner.run(ServerConnection.java:410)
        at org.apache.excalibur.thread.impl.ExecutableRunnable.execute(ExecutableRunnable.java:55)
        at org.apache.excalibur.thread.impl.WorkerThread.run(WorkerThread.java:116)

        do we really need to parse the message to get it as inputstream when we are reading it from a streamrepository???
        Maybe we have to convert 8bit messages to 7bit?

        Show
        bago Stefano Bagnara added a comment - Here is the exception that is thrown: java.io.IOException: Unknown encoding: plain at javax.mail.internet.MimePartDataSource.getInputStream(MimePartDataSource.java:82) at javax.activation.DataHandler.getInputStream(DataHandler.java:220) at javax.mail.internet.MimeMessage.getInputStream(MimeMessage.java:1242) at org.apache.james.core.MimeMessageWrapper.getInputStream(MimeMessageWrapper.java:652) at org.apache.james.core.MailImpl.writeContentTo(MailImpl.java:500) at org.apache.james.pop3server.POP3Handler.doTOP(POP3Handler.java:976) at org.apache.james.pop3server.POP3Handler.parseCommand(POP3Handler.java:491) at org.apache.james.pop3server.POP3Handler.handleConnection(POP3Handler.java:273) at org.apache.james.util.connection.ServerConnection$ClientConnectionRunner.run(ServerConnection.java:410) at org.apache.excalibur.thread.impl.ExecutableRunnable.execute(ExecutableRunnable.java:55) at org.apache.excalibur.thread.impl.WorkerThread.run(WorkerThread.java:116) do we really need to parse the message to get it as inputstream when we are reading it from a streamrepository??? Maybe we have to convert 8bit messages to 7bit?
        Hide
        bago Stefano Bagnara added a comment -

        Hopefully fixed if noone prove that is bad to send the getRawInputStream to the client.

        Show
        bago Stefano Bagnara added a comment - Hopefully fixed if noone prove that is bad to send the getRawInputStream to the client.
        Hide
        danny@apache.org Danny Angus added a comment -

        Closing issue fixed in released version.

        Show
        danny@apache.org Danny Angus added a comment - Closing issue fixed in released version.

          People

          • Assignee:
            bago Stefano Bagnara
            Reporter:
            jglorioso John Glorioso
          • Votes:
            2 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development