Pārlūkot izejas kodu

Fix handling of empty line.

drieseng 4 gadi atpakaļ
vecāks
revīzija
fbadaf8b74
1 mainītis faili ar 4 papildinājumiem un 5 dzēšanām
  1. 4 5
      src/Renci.SshNet/Connection/HttpConnector.cs

+ 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);