bodewig 2004/06/14 05:04:39
Modified: . WHATSNEW
src/main/org/apache/tools/ant/taskdefs/optional/ssh
ScpFromMessage.java
Log:
Don't cripple remote file names that contain spaces.
PR: 26097
Revision Changes Path
1.622 +3 -0 ant/WHATSNEW
Index: WHATSNEW
===================================================================
RCS file: /home/cvs/ant/WHATSNEW,v
retrieving revision 1.621
retrieving revision 1.622
diff -u -r1.621 -r1.622
--- WHATSNEW 12 Jun 2004 16:51:09 -0000 1.621
+++ WHATSNEW 14 Jun 2004 12:04:39 -0000 1.622
@@ -145,6 +145,9 @@
* <zip whenempty="skip"> didn't work in a common situation. Bugzilla
Report 22865.
+* <scp> now properly handles remote files and directories with spaces
+ in their names. Bugzilla Report 26097.
+
Other changes:
--------------
* doc fix concerning the dependencies of the ftp task
1.9 +12 -9
ant/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessage.java
Index: ScpFromMessage.java
===================================================================
RCS file:
/home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessage.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- ScpFromMessage.java 7 Apr 2004 13:30:30 -0000 1.8
+++ ScpFromMessage.java 14 Jun 2004 12:04:39 -0000 1.9
@@ -122,14 +122,14 @@
private File parseAndCreateDirectory(String serverResponse,
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()) {
File dir = new File(localFile, directoryName);
dir.mkdir();
-
+ log("Creating: " + dir);
return dir;
}
return null;
@@ -139,10 +139,13 @@
File localFile,
OutputStream out,
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);
File transferFile = (localFile.isDirectory())
? new File(localFile, filename)
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]