From 9763309a3e3cfaf1e58c9cedc708cbc08c33da3c Mon Sep 17 00:00:00 2001 From: Mark Junker Date: Wed, 22 May 2019 00:46:20 +0200 Subject: [PATCH] Fixed unit test --- .../FtpCommandCollectorTests.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/test/FubarDev.FtpServer.Tests/FtpCommandCollectorTests.cs b/test/FubarDev.FtpServer.Tests/FtpCommandCollectorTests.cs index 8704e04a..573900bd 100644 --- a/test/FubarDev.FtpServer.Tests/FtpCommandCollectorTests.cs +++ b/test/FubarDev.FtpServer.Tests/FtpCommandCollectorTests.cs @@ -178,7 +178,7 @@ public void TestWithCyrillicTextWithWindows1251Encoding() Assert.True(collector.IsEmpty); } - private static IEnumerable> EscapeIAC(byte[] data) + private static IEnumerable> EscapeTelnetCodes(byte[] data) { var startIndex = 0; for (var i = 0; i != data.Length; ++i) @@ -189,6 +189,13 @@ private static IEnumerable> EscapeIAC(byte[] data) yield return new ReadOnlyMemory(data, startIndex, length); startIndex = i; } + else if (data[i] == 0xF2) + { + var length = i - startIndex; + yield return new ReadOnlyMemory(data, startIndex, length); + yield return new ReadOnlyMemory(new byte[] { 0xFF }); + startIndex = i; + } } var remaining = data.Length - startIndex; @@ -201,7 +208,7 @@ private static IEnumerable> EscapeIAC(byte[] data) private static IEnumerable 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)