@@ -394,7 +394,7 @@ def test_frename_success(self):
394394 success , msg = self .ft .frename ("/old.txt" , "/new.txt" )
395395 self .assertTrue (success )
396396 self .mock_fpb .send_fl_cmd .assert_called_with (
397- ' fl -c frename --path " /old.txt" --newpath " /new.txt"' ,
397+ " fl -c frename --path /old.txt --newpath /new.txt" ,
398398 timeout = 2.0 ,
399399 max_retries = 3 ,
400400 )
@@ -1496,21 +1496,27 @@ def test_path_with_carriage_return_rejected(self):
14961496 self .assertIn ("control characters" , str (ctx .exception ))
14971497
14981498 def test_path_with_quotes_escaped (self ):
1499- """Test path with quotes is properly escaped."""
1499+ """Test path with quotes is escaped by sanitize, no wrapping without spaces ."""
15001500 ft = FileTransfer (self .mock_fpb )
15011501 ft .flist ('/path/with"quotes"' )
15021502 call_args = self .mock_fpb .send_fl_cmd .call_args [0 ][0 ]
1503- # Verify quotes are escaped
1504- self .assertIn ('\\ "' , call_args )
1505- # Verify the path is properly quoted
1506- self .assertIn ('--path "/path/with' , call_args )
1503+ # _sanitize_path escapes " to \", no spaces → no wrapping quotes
1504+ self .assertIn ('--path /path/with\\ "quotes\\ "' , call_args )
1505+
1506+ def test_path_with_quotes_and_spaces_escaped (self ):
1507+ """Test path with both quotes and spaces is properly escaped and quoted."""
1508+ ft = FileTransfer (self .mock_fpb )
1509+ ft .flist ('/path/with "quotes"' )
1510+ call_args = self .mock_fpb .send_fl_cmd .call_args [0 ][0 ]
1511+ # _sanitize_path escapes " to \", then _format_path_arg wraps in quotes due to space
1512+ self .assertIn ('--path "/path/with \\ "quotes\\ ""' , call_args )
15071513
15081514 def test_normal_path_unchanged (self ):
1509- """Test normal path works correctly."""
1515+ """Test normal path works correctly without quotes ."""
15101516 ft = FileTransfer (self .mock_fpb )
15111517 ft .fopen ("/normal/path/file.txt" , "r" )
15121518 call_args = self .mock_fpb .send_fl_cmd .call_args [0 ][0 ]
1513- self .assertIn ('" /normal/path/file.txt"' , call_args )
1519+ self .assertIn ("--path /normal/path/file.txt" , call_args )
15141520
15151521 def test_fmkdir_sanitizes_path (self ):
15161522 """Test fmkdir sanitizes path."""
0 commit comments