dfs         2003/08/25 22:43:56

  Modified:    net/src/java/org/apache/commons/net/ftp FTP.java
               net/src/java/org/apache/commons/net/nntp NNTP.java
               net/src/java/org/apache/commons/net/pop3 POP3.java
               net/src/java/org/apache/commons/net/smtp SMTP.java
               net/xdocs changes.xml
  Log:
  [EMAIL PROTECTED] reported failure of SMTP on OS/390 which has EBCDIC as the
  native character set.  I changed the connection hooks (_connectAction_())
  for the FTP, SMTP, POP3, and NNTP classes to force use of an 8-bit
  US-ASCII superset (ISO-8859-1) for protocol communication.  This was
  necessary because InputStreamReader and OutputStreamWriter use the default
  client-side character set encoding.  I don't know if this should be
  user-configurable or if the encodings should be fixed.  Regardless,
  all JVMs are required to support US-ASCII and ISO-8859-1, so there
  shouldn't be a problem with using a fixed encoding.
  
  PR: 22656
  
  Revision  Changes    Path
  1.5       +8 -2      jakarta-commons/net/src/java/org/apache/commons/net/ftp/FTP.java
  
  Index: FTP.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/net/src/java/org/apache/commons/net/ftp/FTP.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- FTP.java  18 May 2003 04:03:16 -0000      1.4
  +++ FTP.java  26 Aug 2003 05:43:55 -0000      1.5
  @@ -244,6 +244,10 @@
        ***/
       public static final int COMPRESSED_TRANSFER_MODE = 12;
   
  +    // We have to ensure that the protocol communication is in ASCII
  +    // but we use ISO-8859-1 just in case 8-bit characters cross
  +    // the wire.
  +    private static final String __DEFAULT_ENCODING = "ISO-8859-1";
       private static final String __modes = "ABILNTCFRPSBC";
   
       private StringBuffer __commandBuffer;
  @@ -349,9 +353,11 @@
       {
           super._connectAction_();
           _controlInput =
  -            new BufferedReader(new InputStreamReader(getInputStream()));
  +            new BufferedReader(new InputStreamReader(getInputStream(),
  +                                                     __DEFAULT_ENCODING));
           _controlOutput =
  -            new BufferedWriter(new OutputStreamWriter(getOutputStream()));
  +            new BufferedWriter(new OutputStreamWriter(getOutputStream(),
  +                                                      __DEFAULT_ENCODING));
           __getReply();
           // If we received code 120, we have to fetch completion reply.
           if (FTPReply.isPositivePreliminary(_replyCode))
  
  
  
  1.6       +9 -2      
jakarta-commons/net/src/java/org/apache/commons/net/nntp/NNTP.java
  
  Index: NNTP.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/net/src/java/org/apache/commons/net/nntp/NNTP.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- NNTP.java 19 Apr 2003 20:49:13 -0000      1.5
  +++ NNTP.java 26 Aug 2003 05:43:55 -0000      1.6
  @@ -120,6 +120,11 @@
       /*** The default NNTP port.  Its value is 119 according to RFC 977. ***/
       public static final int DEFAULT_PORT = 119;
   
  +    // We have to ensure that the protocol communication is in ASCII
  +    // but we use ISO-8859-1 just in case 8-bit characters cross
  +    // the wire.
  +    private static final String __DEFAULT_ENCODING = "ISO-8859-1";
  +
       private StringBuffer __commandBuffer;
   
       boolean _isAllowedToPost;
  @@ -204,9 +209,11 @@
       {
           super._connectAction_();
           _reader_ =
  -            new BufferedReader(new InputStreamReader(_input_));
  +            new BufferedReader(new InputStreamReader(_input_,
  +                                                     __DEFAULT_ENCODING));
           _writer_ =
  -            new BufferedWriter(new OutputStreamWriter(_output_));
  +            new BufferedWriter(new OutputStreamWriter(_output_,
  +                                                      __DEFAULT_ENCODING));
           __getReply();
   
           _isAllowedToPost = (_replyCode == NNTPReply.SERVER_READY_POSTING_ALLOWED);
  
  
  
  1.4       +11 -2     
jakarta-commons/net/src/java/org/apache/commons/net/pop3/POP3.java
  
  Index: POP3.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/net/src/java/org/apache/commons/net/pop3/POP3.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- POP3.java 26 Jan 2003 00:21:44 -0000      1.3
  +++ POP3.java 26 Aug 2003 05:43:55 -0000      1.4
  @@ -109,6 +109,11 @@
       static final String _OK = "+OK";
       static final String _ERROR = "-ERR";
   
  +    // We have to ensure that the protocol communication is in ASCII
  +    // but we use ISO-8859-1 just in case 8-bit characters cross
  +    // the wire.
  +    private static final String __DEFAULT_ENCODING = "ISO-8859-1";
  +
       private int __popState;
       private BufferedWriter __writer;
       private StringBuffer __commandBuffer;
  @@ -173,8 +178,12 @@
       protected void _connectAction_() throws IOException
       {
           super._connectAction_();
  -        _reader = new BufferedReader(new InputStreamReader(_input_));
  -        __writer = new BufferedWriter(new OutputStreamWriter(_output_));
  +        _reader =
  +          new BufferedReader(new InputStreamReader(_input_,
  +                                                   __DEFAULT_ENCODING));
  +        __writer =
  +          new BufferedWriter(new OutputStreamWriter(_output_,
  +                                                    __DEFAULT_ENCODING));
           __getReply();
           setState(AUTHORIZATION_STATE);
       }
  
  
  
  1.5       +17 -2     
jakarta-commons/net/src/java/org/apache/commons/net/smtp/SMTP.java
  
  Index: SMTP.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/net/src/java/org/apache/commons/net/smtp/SMTP.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SMTP.java 18 May 2003 04:03:17 -0000      1.4
  +++ SMTP.java 26 Aug 2003 05:43:55 -0000      1.5
  @@ -125,6 +125,11 @@
       /*** The default SMTP port (25). ***/
       public static final int DEFAULT_PORT = 25;
   
  +    // We have to ensure that the protocol communication is in ASCII
  +    // but we use ISO-8859-1 just in case 8-bit characters cross
  +    // the wire.
  +    private static final String __DEFAULT_ENCODING = "ISO-8859-1";
  +
       private StringBuffer __commandBuffer;
   
       BufferedReader _reader;
  @@ -258,9 +263,11 @@
       {
           super._connectAction_();
           _reader =
  -            new BufferedReader(new InputStreamReader(_input_));
  +            new BufferedReader(new InputStreamReader(_input_,
  +                                                     __DEFAULT_ENCODING));
           _writer =
  -            new BufferedWriter(new OutputStreamWriter(_output_));
  +            new BufferedWriter(new OutputStreamWriter(_output_,
  +                                                      __DEFAULT_ENCODING));
           __getReply();
       }
   
  @@ -781,3 +788,11 @@
       }
   
   }
  +
  +/* Emacs configuration
  + * Local variables:        **
  + * mode:             java  **
  + * c-basic-offset:   4     **
  + * indent-tabs-mode: nil   **
  + * End:                    **
  + */
  
  
  
  1.12      +12 -0     jakarta-commons/net/xdocs/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/net/xdocs/changes.xml,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- changes.xml       25 Aug 2003 22:29:49 -0000      1.11
  +++ changes.xml       26 Aug 2003 05:43:56 -0000      1.12
  @@ -16,6 +16,18 @@
         </action>
   -->
         <action dev="dfs" type="fix">
  +        Changed connection hooks for FTP, SMTP, POP3, and NNTP classes
  +        to force use of an 8-bit US-ASCII superset (ISO-8859-1) for
  +        protocol communication.  This was necessary because
  +        InputStreamReader and OutputStreamWriter use the default
  +        client-side character set encoding.  [EMAIL PROTECTED]
  +        reported failure of SMTP on OS/390 which has EBCDIC as the
  +        native character set.
  +        <pre>
  +        drwxr-xr-x 1 usernameftp 512 Jan 29 23:32 prog
  +        </pre>
  +      </action>
  +      <action dev="dfs" type="fix">
           Applied variation of fix suggested by Matthieu Recouly
           &lt;[EMAIL PROTECTED]&gt; so that
           UnixFTPEntryParser may handle listings of the form
  
  
  

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

Reply via email to