From 8aa8f1700716c2d1a4b5ac73e271fae8a6947d9b Mon Sep 17 00:00:00 2001 From: deniskovalchuk Date: Sat, 23 Sep 2023 02:48:35 +0300 Subject: [PATCH] fix: explicitly handle CRLF newlines when parse file list --- src/file_list_reply.cpp | 4 ++++ test/client.cpp | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/file_list_reply.cpp b/src/file_list_reply.cpp index 17c6735..25740b1 100644 --- a/src/file_list_reply.cpp +++ b/src/file_list_reply.cpp @@ -57,6 +57,10 @@ std::vector file_list_reply::parse_file_list(const std::string & fi std::string line; while (std::getline(iss, line)) { + /* Handle CRLF. */ + if (!line.empty() && line.back() == '\r') + line.pop_back(); + file_list.push_back(line); } diff --git a/test/client.cpp b/test/client.cpp index 86935e6..f2727e8 100644 --- a/test/client.cpp +++ b/test/client.cpp @@ -774,8 +774,6 @@ TEST_F(client, get_file_list_only_names) "230 Login successful.", "200 Type set to: Binary.")); - client.set_transfer_type(ftp::transfer_type::ascii); - ftp::file_list_reply reply = client.get_file_list(".", true); check_last_reply(reply, "226 Transfer complete."); ASSERT_THAT(reply.get_file_list(), ElementsAre());