james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hb...@apache.org
Subject cvs commit: jakarta-james/src/java/org/apache/james/nntpserver/repository NNTPArticleImpl.java
Date Sat, 07 Sep 2002 06:16:14 GMT
hbedi       2002/09/06 23:16:14

  Modified:    src/java/org/apache/james/nntpserver/repository
                        NNTPArticleImpl.java
  Log:
  patch from Christian Buchegger <christian.buchegger@planet-interkom.de>
  
  snippet his email:
  
     Looking at RFC2980: 2.8 XOVER I found:
     >> Note that any tab and end-of-line characters in any header data
     >> that is returned will be converted to a space character.
     ...
     The attached patch does this filtering.
     ...
     uses a StringBuffer and a single call to prt.println() instead many
     calls to prt.print(). This allowed to trace the communication
     between server and client
  
  Revision  Changes    Path
  1.6       +24 -8     jakarta-james/src/java/org/apache/james/nntpserver/repository/NNTPArticleImpl.java
  
  Index: NNTPArticleImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/nntpserver/repository/NNTPArticleImpl.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- NNTPArticleImpl.java	8 Aug 2002 00:43:29 -0000	1.5
  +++ NNTPArticleImpl.java	7 Sep 2002 06:16:14 -0000	1.6
  @@ -84,6 +84,20 @@
           } catch(IOException ex) { throw new NNTPException(ex); }
       }
   
  +    // rfc2980: 2.8 XOVER
  +    // requires newline and tab to be converted to space
  +    private String cleanHeader(String field) {
  +        if ( field == null )
  +            field = "";
  +        StringBuffer sb = new StringBuffer(field);
  +        for( int i=0 ; i<sb.length() ; i++ ) {
  +            char c = sb.charAt(i);
  +            if( (c=='\n') || (c=='\t') ) 
  +                sb.setCharAt(i, ' ');
  +        }
  +        return sb.toString();
  +    }
  +    
       public void writeOverview(PrintWriter prt) {
           try {
               FileInputStream fin = new FileInputStream(f);
  @@ -97,14 +111,16 @@
               String references = hdr.getHeader("References",null);
               long byteCount = f.length();
               long lineCount = -1;
  -            prt.print(articleNumber + "\t");
  -            prt.print((subject==null?"":subject) + "\t");
  -            prt.print((author==null?"":author) + "\t");
  -            prt.print((date==null?"":date) + "\t");
  -            prt.print((msgId==null?"":msgId) + "\t");
  -            prt.print((references==null?"":references) + "\t");
  -            prt.print(byteCount + "\t");
  -            prt.println(lineCount + "");
  +            StringBuffer line=new StringBuffer(128)
  +                .append(articleNumber + "\t")
  +                .append(cleanHeader(subject))    .append("\t")
  +                .append(cleanHeader(author))     .append("\t")
  +                .append(cleanHeader(date))       .append("\t")
  +                .append(cleanHeader(msgId))      .append("\t")
  +                .append(cleanHeader(references)) .append("\t")         
  +                .append(byteCount + "\t")
  +                .append(lineCount + "");
  +            prt.println(line.toString());
           } catch(Exception ex) { throw new NNTPException(ex); }
       }
       public String getHeader(String header) {
  
  
  

--
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