2
0
Эх сурвалжийг харах

Fix handling of empty line.

drieseng 4 жил өмнө
parent
commit
fbadaf8b74

+ 4 - 5
src/Renci.SshNet/Connection/HttpConnector.cs

@@ -118,14 +118,13 @@ namespace Renci.SshNet.Connection
                     break;
 
                 var b = data[0];
+                buffer.Add(b);
 
-                if (b == Session.LineFeed && buffer.Count > 1 && buffer[buffer.Count - 1] == Session.CarriageReturn)
+                if (b == Session.LineFeed && buffer.Count > 1 && buffer[buffer.Count - 2] == Session.CarriageReturn)
                 {
-                    // Return line without CR
-                    return encoding.GetString(buffer.ToArray(), 0, buffer.Count - 1);
+                    // Return line without CRLF
+                    return encoding.GetString(buffer.ToArray(), 0, buffer.Count - 2);
                 }
-
-                buffer.Add(b);
             }
             while (true);