commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1614785 - in /commons/proper/net/trunk/src: changes/changes.xml main/java/org/apache/commons/net/telnet/TelnetOutputStream.java
Date Wed, 30 Jul 2014 22:28:51 GMT
Author: sebb
Date: Wed Jul 30 22:28:51 2014
New Revision: 1614785

URL: http://svn.apache.org/r1614785
Log:
NET-549 - Telnet does not convert LF to CRLF in ASCII mode

Modified:
    commons/proper/net/trunk/src/changes/changes.xml
    commons/proper/net/trunk/src/main/java/org/apache/commons/net/telnet/TelnetOutputStream.java

Modified: commons/proper/net/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/changes/changes.xml?rev=1614785&r1=1614784&r2=1614785&view=diff
==============================================================================
--- commons/proper/net/trunk/src/changes/changes.xml [utf-8] (original)
+++ commons/proper/net/trunk/src/changes/changes.xml [utf-8] Wed Jul 30 22:28:51 2014
@@ -68,6 +68,9 @@ This is mainly a bug-fix release. See fu
   IMAPExportMbox (example app) allows IMAP folders to be exported into an mbox file.
   This is the inverse of the IMAPImportMbox example added previously
         ">
+            <action issue="NET-549" type="fix" dev="sebb" due-to="Pradeep Natarajan">
+            Telnet does not convert LF to CRLF in ASCII mode
+            </action>
             <action issue="NET-543" type="fix" dev="sebb" due-to="Ferry Huberts">
             telnet: spy read EOL is reversed
             </action>

Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/telnet/TelnetOutputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/telnet/TelnetOutputStream.java?rev=1614785&r1=1614784&r2=1614785&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/org/apache/commons/net/telnet/TelnetOutputStream.java
(original)
+++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/telnet/TelnetOutputStream.java
Wed Jul 30 22:28:51 2014
@@ -25,8 +25,9 @@ import java.io.OutputStream;
  * <p>
  * In binary mode, the only conversion is to double IAC.
  * <p>
- * In ASCII mode, if convertCRtoCRLF is true, any CR is converted to CRLF.
+ * In ASCII mode, if convertCRtoCRLF is true (currently always true), any CR is converted
to CRLF.
  * IACs are doubled.
+ * Also a bare LF is converted to CRLF and a bare CR is converted to CR\0
  * <p>
  ***/
 
@@ -78,20 +79,27 @@ final class TelnetOutputStream extends O
                     }
                 }
 
-                __lastWasCR = false;
-
                 switch (ch)
                 {
                 case '\r':
                     __client._sendByte('\r');
                     __lastWasCR = true;
                     break;
+                case '\n':
+                    if (!__lastWasCR) { // convert LF to CRLF
+                        __client._sendByte('\r');
+                    }
+                    __client._sendByte(ch);
+                    __lastWasCR = false;
+                    break;
                 case TelnetCommand.IAC:
                     __client._sendByte(TelnetCommand.IAC);
                     __client._sendByte(TelnetCommand.IAC);
+                    __lastWasCR = false;
                     break;
                 default:
                     __client._sendByte(ch);
+                    __lastWasCR = false;
                     break;
                 }
             } // end ASCII



Mime
View raw message