Skip to content

Commit

Permalink
Fixed unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
fubar-coder committed May 21, 2019
1 parent f9c6e78 commit 9763309
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions test/FubarDev.FtpServer.Tests/FtpCommandCollectorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public void TestWithCyrillicTextWithWindows1251Encoding()
Assert.True(collector.IsEmpty);
}

private static IEnumerable<ReadOnlyMemory<byte>> EscapeIAC(byte[] data)
private static IEnumerable<ReadOnlyMemory<byte>> EscapeTelnetCodes(byte[] data)
{
var startIndex = 0;
for (var i = 0; i != data.Length; ++i)
Expand All @@ -189,6 +189,13 @@ private static IEnumerable<ReadOnlyMemory<byte>> EscapeIAC(byte[] data)
yield return new ReadOnlyMemory<byte>(data, startIndex, length);
startIndex = i;
}
else if (data[i] == 0xF2)
{
var length = i - startIndex;
yield return new ReadOnlyMemory<byte>(data, startIndex, length);
yield return new ReadOnlyMemory<byte>(new byte[] { 0xFF });
startIndex = i;
}
}

var remaining = data.Length - startIndex;
Expand All @@ -201,7 +208,7 @@ private static IEnumerable<ReadOnlyMemory<byte>> EscapeIAC(byte[] data)
private static IEnumerable<FtpCommand> Collect(FtpCommandCollector collector, string data)
{
var temp = collector.Encoding.GetBytes(data);
foreach (var escapedDataMemory in EscapeIAC(temp))
foreach (var escapedDataMemory in EscapeTelnetCodes(temp))
{
var collected = collector.Collect(escapedDataMemory.Span);
foreach (var command in collected)
Expand Down

0 comments on commit 9763309

Please sign in to comment.