james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject cvs commit: jakarta-james/src/java/org/apache/james/util ExtraDotOutputStream.java
Date Wed, 27 Feb 2002 04:47:41 GMT
serge       02/02/26 20:47:41

  Added:       src/java/org/apache/james/util ExtraDotOutputStream.java
  Log:
  Added dot-stuffing when retrieving a message in POP3.  Thanks to Stephan Schiessling <s@rapi.com>
  
  Revision  Changes    Path
  1.1                  jakarta-james/src/java/org/apache/james/util/ExtraDotOutputStream.java
  
  Index: ExtraDotOutputStream.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE file.
   */
  package org.apache.james.util;
  
  import java.io.FilterOutputStream;
  import java.io.IOException;
  import java.io.OutputStream;
  
  /**
   * Adds extra dot if dot occurs in message body at beginning of line (according to RFC1939)
   * Compare also org.apache.james.smtpserver.SMTPInputStream
   *
   * @author Stephan Schiessling <s@rapi.com>
   */
  public class ExtraDotOutputStream extends FilterOutputStream {
  
      /**
       * Counter for number of last (0A or 0D).
       */
      protected int countLast0A0D;
  
      public ExtraDotOutputStream(OutputStream out) {
          super(out);
          countLast0A0D = 2; // we already assume a CRLF at beginning (otherwise TOP would
not work correctly !)
      }
  
      public void write(int b) throws IOException {
          out.write(b);
          if (b == '.') {
              if (countLast0A0D > 1) {
                  // add extra dot
                  out.write('.');
              }
              countLast0A0D = 0;
          } else {
              if (b == '\r' || b == '\n') {
                  countLast0A0D++;
              } else {
                  countLast0A0D = 0;
              }
          }
      }
  
  }
  
  
  
  

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


Mime
View raw message