james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject cvs commit: jakarta-james/src/java/org/apache/james/smtpserver SMTPHandler.java
Date Wed, 04 Jun 2003 23:21:12 GMT
noel        2003/06/04 16:21:12

  Modified:    src/java/org/apache/james/smtpserver Tag: branch_2_1_fcs
                        SMTPHandler.java
  Log:
  Use CRLFTerminatedReader.  Respond with a detailed 501 to explain a syntax error.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.35.4.12 +11 -6     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.35.4.11
  retrieving revision 1.35.4.12
  diff -u -r1.35.4.11 -r1.35.4.12
  --- SMTPHandler.java	26 May 2003 06:06:47 -0000	1.35.4.11
  +++ SMTPHandler.java	4 Jun 2003 23:21:12 -0000	1.35.4.12
  @@ -341,7 +341,8 @@
               // 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);
  +            // inReader = new BufferedReader(new InputStreamReader(in, "ASCII"), 512);
  +            inReader = new CRLFTerminatedReader(in, "ASCII");
               remoteIP = socket.getInetAddress().getHostAddress();
               remoteHost = socket.getInetAddress().getHostName();
               smtpID = random.nextInt(1024) + "";
  @@ -536,11 +537,15 @@
        * @throws IOException if an exception is generated reading in the input characters
        */
       final String readCommandLine() throws IOException {
  -        String commandLine = inReader.readLine();
  -        if (commandLine != null) {
  -            commandLine = commandLine.trim();
  +        for (;;) try {
  +            String commandLine = inReader.readLine();
  +            if (commandLine != null) {
  +                commandLine = commandLine.trim();
  +            }
  +            return commandLine;
  +        } catch (CRLFTerminatedReader.TerminationException te) {
  +            writeLoggedFlushedResponse("501 Syntax error at character position " + te.position()
+ ". CR and LF must be CRLF paired.  See RFC 2821 #2.7.1.");
           }
  -        return commandLine;
       }
   
       /**
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: james-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: james-dev-help@jakarta.apache.org


Mime
View raw message