-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Hotfix][Connector-V2][SFTP] Add quote to sftp file names with wildcard characters #8501
base: dev
Are you sure you want to change the base?
Conversation
…rd characters before get input stream
@e-mhui Thank you for your contribution. Please open ci according to the guidance and add the tests corresponding to the modified parts. |
Ok, I'll add the test later. |
…rd characters before get input stream
…rd characters before get input stream
...tor-file-sftp-e2e/src/test/java/org/apache/seatunnel/e2e/connector/file/fstp/SftpFileIT.java
Show resolved
Hide resolved
...tor-file-sftp-e2e/src/test/java/org/apache/seatunnel/e2e/connector/file/fstp/SftpFileIT.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @e-mhui , does other file system will face same problems?
@Hisoka-X Other file systems will not have this problem. This is because the code in jsch uses public InputStream get(String src, final SftpProgressMonitor monitor, final long skip) throws SftpException{
try{
((MyPipedInputStream)io_in).updateReadSide();
src=remoteAbsolutePath(src);
src=isUnique(src);
//........
}
}
/**
* This method will check if the given string can be expanded to the
* unique string. If it can be expanded to mutiple files, SftpException
* will be thrown.
* @return the returned string is unquoted.
*/
private String isUnique(String path) throws SftpException, Exception{
Vector v=glob_remote(path);
if(v.size()!=1){
throw new SftpException(SSH_FX_FAILURE, path+" is not unique: "+v.toString());
}
return (String)(v.elementAt(0));
} |
private String quote(String path) { | ||
byte[] _path = path.getBytes(StandardCharsets.UTF_8); | ||
int count = 0; | ||
for (int i = 0; i < _path.length; i++) { | ||
byte b = _path[i]; | ||
if (b == '\\' || b == '?' || b == '*') { | ||
count++; | ||
} | ||
} | ||
if (count == 0) { | ||
return path; | ||
} | ||
byte[] _path2 = new byte[_path.length + count]; | ||
for (int i = 0, j = 0; i < _path.length; i++) { | ||
byte b = _path[i]; | ||
if (b == '\\' || b == '?' || b == '*') { | ||
_path2[j++] = '\\'; | ||
} | ||
_path2[j++] = b; | ||
} | ||
return new String(_path2, 0, _path2.length, StandardCharsets.UTF_8); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a UT for this method.
rules { | ||
row_rules = [ | ||
{ | ||
rule_type = MAX_ROW |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rule_type = MAX_ROW | |
rule_type = MIN_ROW |
[Hotfix][Connector-V2][SFTP] Add quote to sftp file names with wildcard characters
Purpose of this pull request
Fix #8500.
Does this PR introduce any user-facing change?
No.
How was this patch tested?
Check list
New License Guide
release-note
.