noel        2003/02/06 13:08:04

  Modified:    src/java/org/apache/james/smtpserver SMTPHandler.java
  Log:
  Restore earlier version of readCommandLine.  Fix bug 16847 (unrelated to the restore)
  
  Revision  Changes    Path
  1.44      +18 -27    
jakarta-james/src/java/org/apache/james/smtpserver/SMTPHandler.java
  
  Index: SMTPHandler.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-james/src/java/org/apache/james/smtpserver/SMTPHandler.java,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- SMTPHandler.java  6 Feb 2003 06:36:17 -0000       1.43
  +++ SMTPHandler.java  6 Feb 2003 21:08:04 -0000       1.44
  @@ -185,6 +185,11 @@
       private PrintWriter out;
   
       /**
  +     * A Reader wrapper for the incoming stream of bytes coming from the socket.
  +     */
  +    private BufferedReader inReader;
  +
  +    /**
        * The remote host name obtained by lookup on the socket.
        */
       private String remoteHost;
  @@ -295,6 +300,10 @@
                   handlerThread = Thread.currentThread();
               }
               in = new BufferedInputStream(socket.getInputStream(), 1024);
  +            // An ASCII encoding can be used because all transmissions other
  +            // that those in the DATA command are guaranteed
  +            // to be ASCII
  +            inReader = new BufferedReader(new InputStreamReader(in, "ASCII"), 512);
               remoteIP = socket.getInetAddress().getHostAddress();
               remoteHost = socket.getInetAddress().getHostName();
               smtpID = random.nextInt(1024) + "";
  @@ -398,6 +407,7 @@
   
           clearResponseBuffer();
           in = null;
  +        inReader = null;
           out = null;
           remoteHost = null;
           remoteIP = null;
  @@ -486,31 +496,11 @@
        * @throws IOException if an exception is generated reading in the input 
characters
        */
       final String readCommandLine() throws IOException {
  -        //Read through for \r or \n
  -        ByteArrayOutputStream bout = new ByteArrayOutputStream();
  -        byte b = -1;
  -        while (true) {
  -            b = (byte) in.read();
  -            if (b == 13) {
  -                //We're done, but we want to see if \n is next
  -                in.mark(1);
  -                b = (byte) in.read();
  -                if (b != 10) {
  -                    in.reset();
  -                }
  -                break;
  -            } else if (b == 10) {
  -                //We're done
  -                break;
  -            } else if (b == -1) {
  -                break;
  -            }
  -            bout.write(b);
  -        }
  -        // An ASCII encoding can be used because all transmissions other
  -        // that those in the DATA command are guaranteed
  -        // to be ASCII
  -        return bout.toString("ASCII").trim();
  +        String commandLine = inReader.readLine();
  +        if (commandLine != null) {
  +            commandLine = commandLine.trim();
  +        }
  +        return commandLine;
       }
   
       /**
  @@ -869,7 +859,8 @@
               writeLoggedFlushedResponse(responseString);
           } else {
               sender = sender.trim();
  -            int lastChar = sender.lastIndexOf('>');
  +            // the next gt after the first lt ... AUTH may add more <>
  +            int lastChar = sender.indexOf('>', sender.indexOf('<'));
               // Check to see if any options are present and, if so, whether they are 
correctly formatted
               // (separated from the closing angle bracket by a ' ').
               if ((lastChar > 0) && (sender.length() > lastChar + 2) && 
(sender.charAt(lastChar + 1) == ' ')) {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to