[
https://issues.apache.org/jira/browse/CAMEL-26925?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Work on CAMEL-26925 started by Claus Ibsen.
-------------------------------------------
> camel-sftp - use remote file names literally when calling JSch
> --------------------------------------------------------------
>
> Key: CAMEL-26925
> URL: https://issues.apache.org/jira/browse/CAMEL-26925
> Project: Camel
> Issue Type: Bug
> Components: camel-ftp, camel-sftp
> Reporter: Claus Ibsen
> Assignee: Claus Ibsen
> Priority: Major
> Fix For: 4.18.6, 4.22.3, 4.24.0
>
>
> The sftp component (SftpOperations in camel-ftp) passes remote paths as they
> are to the JSch ChannelSftp methods that take a path, such as put, get, rm,
> rename, ls and cd. JSch reads {{*}} and {{?}} in such a path as a pattern and
> {{\}} as an escape character. A remote file or directory name that contains
> one of these characters is therefore matched against the names in the
> directory instead of being used as is, while the rest of Camel (the file and
> ftp components, and camel-mina-sftp) uses the name literally.
> SftpOperations already escapes the path with quotePathForJsch for lstat and
> readlink.
> *Today*
> * A remote file or directory name with {{*}}, {{?}} or {{\}} is not used
> literally by the sftp producer and consumer: storing, retrieving, deleting,
> renaming and changing directory resolve the name through JSch pattern
> matching.
> *After the change*
> * Every path argument that JSch interprets is escaped, so sftp works on the
> file or directory with exactly the given name, the same as the other file
> based components.
> * A name that uses {{*}} or {{?}} to select files (for example a fixed
> fileName with useList=false, or a pattern in the CamelFileName header) no
> longer selects files; use the include or antInclude options instead. This
> goes in the upgrade guide.
> *Code*
> * SftpOperations: pass the path through quotePathForJsch at each ChannelSftp
> call that interprets it (rm, rename source and target, put, get, cd, ls and
> the other path based calls, including the existence checks). mkdir and
> realpath are left unchanged, as JSch sends their argument without
> interpreting it.
> * Escape at the ChannelSftp call only, so names, headers and log messages in
> Camel stay unchanged.
> *Tests*
> * New integration tests in camel-ftp on the embedded SFTP server of
> camel-test-infra-ftp (like SftpExistsFileIT), producer and consumer, with
> file and directory names that contain {{*}}, {{?}} and {{\}}. Each test
> checks that the file with the given name is the one stored, consumed, deleted
> or moved, and that the other files of the directory are unchanged.
> *Docs*
> * Upgrade guide note for 4.24, and for 4.22.3 and 4.18.6 (on main), about
> names now being used literally.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)