You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to list items in a directory with a space in the file name data after the space gets truncated.
I have created a small test for this:
use unftp_sbe_fs::ServerExt;#[tokio::main(flavor = "current_thread")]asyncfnmain(){
pretty_env_logger::init();let addr = "127.0.0.1:2121";let server = libunftp::Server::with_fs("./test/").build().unwrap();println!("Starting ftp server on {}", addr);
server.listen(addr).await.unwrap();}#[cfg(test)]mod tests {#[test]fntest_list_item_with_space(){
pretty_env_logger::init();use ftp::FtpStream;letmut ftp_stream =
FtpStream::connect("localhost:2121").unwrap_or_else(|err| panic!("{}", err));
ftp_stream.login("anonymous","anonymous").unwrap();let folder_name_with_space = "test with space";// Make test folder as well as subfolder
ftp_stream.mkdir(folder_name_with_space).unwrap();
ftp_stream.mkdir(format!("{}/{}", folder_name_with_space,"cool").as_str()).unwrap();
ftp_stream
.list(folder_name_with_space.into()).unwrap().iter().for_each(|item| {println!("{:?}", item);});let _ = ftp_stream.quit();}}
The expected output of the print statement would be something along the lines of: "drwxr-xr-x 1 0 0 0 Jan 18 21:30 cool"
However test fails with an error of: InvalidResponse("Expected code [226, 250], got response: 550 File not found\r\n")
It looks like from the logs the path got truncated: DEBUG libunftp::server::datachan > Data channel command received: List { options: None, path: Some("test") }, username: anonymous, source: 127.0.0.1:58510, trace-id: 0xbc8265330a20d513, path: test
The text was updated successfully, but these errors were encountered:
I am not 100% sure what this function should be doing but the assumption is that it is trying to parse out the provided line and skip any items that start with a '-'.
Maybe we could collect the results back into a string for example:
let path = line
.split(|&b| b == b' ').filter(|s| !line.is_empty() && !s.starts_with(b"-")).map(|s| String::from_utf8_lossy(s).to_string()).collect::<Vec<_>>().join(" ");
However, not sure if this is exactly what we want, not too sure of the FTP spec for list and what it could contain. As with the above we will still have an issue if an argument has extra info separated by a space eg --test somevalue
When trying to list items in a directory with a space in the file name data after the space gets truncated.
I have created a small test for this:
The expected output of the print statement would be something along the lines of:
"drwxr-xr-x 1 0 0 0 Jan 18 21:30 cool"
However test fails with an error of:
InvalidResponse("Expected code [226, 250], got response: 550 File not found\r\n")
It looks like from the logs the path got truncated:
DEBUG libunftp::server::datachan > Data channel command received: List { options: None, path: Some("test") }, username: anonymous, source: 127.0.0.1:58510, trace-id: 0xbc8265330a20d513, path: test
The text was updated successfully, but these errors were encountered: