Browse Source

Don't cripple remote file names that contain spaces.

PR: 26097


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@276578 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 21 years ago
parent
commit
306324c7f1
2 changed files with 15 additions and 9 deletions
  1. +3
    -0
      WHATSNEW
  2. +12
    -9
      src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessage.java

+ 3
- 0
WHATSNEW View File

@@ -145,6 +145,9 @@ Fixed bugs:
* <zip whenempty="skip"> didn't work in a common situation. Bugzilla * <zip whenempty="skip"> didn't work in a common situation. Bugzilla
Report 22865. Report 22865.


* <scp> now properly handles remote files and directories with spaces
in their names. Bugzilla Report 26097.

Other changes: Other changes:
-------------- --------------
* doc fix concerning the dependencies of the ftp task * doc fix concerning the dependencies of the ftp task


+ 12
- 9
src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessage.java View File

@@ -122,14 +122,14 @@ public class ScpFromMessage extends AbstractSshMessage {


private File parseAndCreateDirectory(String serverResponse, private File parseAndCreateDirectory(String serverResponse,
File localFile) { File localFile) {
StringTokenizer token = new StringTokenizer(serverResponse);
String command = token.nextToken();
token.nextToken(); // appears that this is not used and it's zero.
String directoryName = token.nextToken();
int start = serverResponse.indexOf(" ");
// appears that the next token is not used and it's zero.
start = serverResponse.indexOf(" ", start + 1);
String directoryName = serverResponse.substring(start + 1);
if (localFile.isDirectory()) { if (localFile.isDirectory()) {
File dir = new File(localFile, directoryName); File dir = new File(localFile, directoryName);
dir.mkdir(); dir.mkdir();
log("Creating: " + dir);
return dir; return dir;
} }
return null; return null;
@@ -139,10 +139,13 @@ public class ScpFromMessage extends AbstractSshMessage {
File localFile, File localFile,
OutputStream out, OutputStream out,
InputStream in) throws IOException { InputStream in) throws IOException {
StringTokenizer token = new StringTokenizer(serverResponse);
String command = token.nextToken();
int filesize = Integer.parseInt(token.nextToken());
String filename = token.nextToken();
int start = 0;
int end = serverResponse.indexOf(" ", start + 1);
String command = serverResponse.substring(start, end);
start = end + 1;
end = serverResponse.indexOf(" ", start + 1);
int filesize = Integer.parseInt(serverResponse.substring(start, end));
String filename = serverResponse.substring(end + 1);
log("Receiving: " + filename + " : " + filesize); log("Receiving: " + filename + " : " + filesize);
File transferFile = (localFile.isDirectory()) File transferFile = (localFile.isDirectory())
? new File(localFile, filename) ? new File(localFile, filename)


Loading…
Cancel
Save