From f5dd2804881fac39639d85424ee56033afd7fb1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Sat, 18 Jun 2022 13:14:42 +0200 Subject: [PATCH 1/2] Improve path separator handling on windows --- src/server/controlchan/commands/pwd.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/server/controlchan/commands/pwd.rs b/src/server/controlchan/commands/pwd.rs index 8299f03a..1d57ed4c 100644 --- a/src/server/controlchan/commands/pwd.rs +++ b/src/server/controlchan/commands/pwd.rs @@ -28,9 +28,15 @@ where async fn handle(&self, args: CommandContext) -> Result { let session = args.session.lock().await; // TODO: properly escape double quotes in `cwd` - Ok(Reply::new_with_string( - ReplyCode::DirCreated, - format!("\"{}\"", session.cwd.as_path().display()), - )) + + let result = format!("\"{}\"", session.cwd.as_path().display()); + + // On Windows systems, the path will be formatted with Windows style separators ('\') + // Most FTP clients expect normal UNIX separators ('/'), and they have trouble handling + // Windows style separators, so if we are on a Windows host, we replace the separators here. + #[cfg(windows)] + let result = result.replace(std::path::MAIN_SEPARATOR, "/"); + + Ok(Reply::new_with_string(ReplyCode::DirCreated, result)) } } From c9d253681e18e6f5f91edf7b5c7450ebf37e3a59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Sat, 18 Jun 2022 13:14:59 +0200 Subject: [PATCH 2/2] Add missing import to make tests compile --- src/server/proxy_protocol.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/proxy_protocol.rs b/src/server/proxy_protocol.rs index 64a2eacd..b17fd53d 100644 --- a/src/server/proxy_protocol.rs +++ b/src/server/proxy_protocol.rs @@ -219,7 +219,7 @@ where mod tests { use super::ProxyError; use proxy_protocol::{version1::ProxyAddresses, ProxyHeader}; - use std::net::SocketAddrV4; + use std::net::{SocketAddrV4, Ipv4Addr}; use std::time::Duration; use tokio::io::AsyncWriteExt; use tokio::time::sleep;