Repository: mina-sshd
Updated Branches:
  refs/heads/master 0639c7c0b -> 0f547d822


[SSHD-429] Take into account local file separator when sending/receiving files 
via SCP


Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/0f547d82
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/0f547d82
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/0f547d82

Branch: refs/heads/master
Commit: 0f547d82230ac1377f852201853c62f710dd5297
Parents: 0639c7c
Author: Guillaume Nodet <[email protected]>
Authored: Mon Mar 23 09:06:42 2015 +0100
Committer: Guillaume Nodet <[email protected]>
Committed: Mon Mar 23 09:06:42 2015 +0100

----------------------------------------------------------------------
 .../main/java/org/apache/sshd/common/scp/ScpHelper.java | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/0f547d82/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpHelper.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpHelper.java 
b/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpHelper.java
index 7c8897c..b48611e 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpHelper.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/scp/ScpHelper.java
@@ -330,10 +330,12 @@ public class ScpHelper {
     public void send(List<String> paths, boolean recursive, boolean preserve, 
int bufferSize) throws IOException {
         readAck(false);
         for (String pattern : paths) {
+            pattern = pattern.replace('/', File.separatorChar);
+
             int idx = pattern.indexOf('*');
             if (idx >= 0) {
                 String basedir = "";
-                int lastSep = pattern.substring(0, idx).lastIndexOf('/');
+                int lastSep = pattern.substring(0, 
idx).lastIndexOf(File.separatorChar);
                 if (lastSep >= 0) {
                     basedir = pattern.substring(0, lastSep);
                     pattern = pattern.substring(lastSep + 1);
@@ -346,18 +348,18 @@ public class ScpHelper {
                     } else if (Files.isDirectory(file)) {
                         if (!recursive) {
                             out.write(ScpHelper.WARNING);
-                            out.write((path + " not a regular 
file\n").getBytes());
+                            
out.write((path.toString().replace(File.separatorChar, '/') + " not a regular 
file\n").getBytes());
                         } else {
                             sendDir(file, preserve, bufferSize);
                         }
                     } else {
                         out.write(ScpHelper.WARNING);
-                        out.write((path + " unknown file type\n").getBytes());
+                        out.write((path.toString().replace(File.separatorChar, 
'/') + " unknown file type\n").getBytes());
                     }
                 }
             } else {
                 String basedir = "";
-                int lastSep = pattern.lastIndexOf('/');
+                int lastSep = pattern.lastIndexOf(File.separatorChar);
                 if (lastSep >= 0) {
                     basedir = pattern.substring(0, lastSep);
                     pattern = pattern.substring(lastSep + 1);
@@ -385,7 +387,7 @@ public class ScpHelper {
         if (GenericUtils.isEmpty(basedir)) {
             return resolveLocalPath(subpath);
         } else {
-            return resolveLocalPath(basedir + "/" + subpath);
+            return resolveLocalPath(basedir + File.separator + subpath);
         }
     }
 

Reply via email to