Skip to content

Commit

Permalink
fix: explicitly handle CRLF newlines when parse file list
Browse files Browse the repository at this point in the history
  • Loading branch information
deniskovalchuk committed Sep 22, 2023
1 parent be8788b commit 8aa8f17
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/file_list_reply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ std::vector<std::string> 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);
}

Expand Down
2 changes: 0 additions & 2 deletions test/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit 8aa8f17

Please sign in to comment.