davsclaus opened a new pull request, #30211:
URL: https://github.com/apache/camel/pull/30211

   ## Summary
   
   [CAMEL-27054](https://issues.apache.org/jira/browse/CAMEL-27054)
   
   The FTP control connection sends one command per line. The `ftp` and `ftps` 
file operations put the remote file or directory name into the argument of 
commands such as STOR, APPE, DELE, RNFR/RNTO, MKD, CWD and NLST, and a name 
with a carriage return or a line feed was sent as is. Such a name cannot be 
sent as one command: the server got the name cut at the line break, so the 
operation failed or acted on another file, and the replies of the later 
commands on the connection could get out of step. Like the `scp` producer does 
for a line feed, the `ftp` and `ftps` components now refuse such a name with a 
clear error.
   
   ## Changes
   
   - `FtpOperations` (also used by `FtpsOperations`) checks every remote name 
before it sends a command for it: store (also append, the existence checks of 
`fileExist`, `chmod`), store directly (done files), delete, rename (from and 
to), build directory, change directory, exists, retrieve and list. A name with 
a carriage return or a line feed fails with a 
`GenericFileOperationFailedException` whose message gives the character code 
and its index, not the name. Nothing is sent to the server for it.
   - The operator's own `siteCommand` option, which is split on new lines on 
purpose, is unchanged. `sftp` is not changed.
   - `FakeFtpServer` (test helper) records every command line it receives.
   - Docs: a short section in the FTP component page (and the catalog copy).
   - Upgrade guide: an entry for 4.24, and on main the entries for 4.22.3 and 
4.18.6, where the change will be backported.
   
   ## Tests
   
   - `FtpProducerFileNameLineBreakTest` (unit, `FakeFtpServer`): a CR, a LF and 
a CR LF in `CamelFileName`, in a directory of the name, and with 
`stepwise=false`, `tempFileName`, `tempPrefix`, 
`fileExist=Move|Append|Fail|Ignore` (with `fastExistsCheck`), `chmod` and 
`doneFileName`; each exchange fails and the server receives no command with the 
name. A test calls each `FtpOperations` method with such a name. A plain name 
with `tempFileName`, `doneFileName` and `chmod` is stored as before.
   - `FtpProducerFileNameLineBreakIT` (embedded FTP server): a file name and a 
directory name with a line break are refused and nothing is created on the 
server; a plain name is stored.
   - Both tests fail without the change in `FtpOperations`.
   
   _Claude Code on behalf of Claus Ibsen_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to