Skip to content

Commit

Permalink
Fixes Issue #551 pscp command line arguments now properly encapsulate…
Browse files Browse the repository at this point in the history
…d in quotation marks to deal with spaces in folder names
  • Loading branch information
jimradford committed Oct 16, 2015
1 parent c303ca5 commit 618cc02
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
2 changes: 1 addition & 1 deletion SuperPutty/PscpTransfer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ static string MakeArgs(SessionData session, bool includePassword, string path)
: "";
args += "-P " + session.Port + " ";
args += (!String.IsNullOrEmpty(session.Username)) ? session.Username + "@" : "";
args += session.Host + ":" + path;
args += session.Host + ":\"" + path + "\"";

return args;
}
Expand Down
19 changes: 7 additions & 12 deletions SuperPutty/Scp/PscpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public static string ToArgs(SessionData session, string password, string path)
sb.AppendFormat("-pw {0} ", password);
}
sb.AppendFormat("-P {0} ", session.Port);
sb.AppendFormat("{0}@{1}:{2}", session.Username, session.Host, path);
sb.AppendFormat("{0}@{1}:\"{2}\"", session.Username, session.Host, path);

return sb.ToString();
}
Expand Down Expand Up @@ -219,7 +219,7 @@ public FileTransferResult CopyFiles(List<BrowserFileInfo> sourceFiles, BrowserFi
}
}

static string ToArgs(SessionData session, string password, List<BrowserFileInfo> source, BrowserFileInfo target)
private static string ToArgs(SessionData session, string password, List<BrowserFileInfo> source, BrowserFileInfo target)
{
StringBuilder sb = new StringBuilder();

Expand All @@ -241,26 +241,21 @@ static string ToArgs(SessionData session, string password, List<BrowserFileInfo>
{
sb.AppendFormat("\"{0}\" ", file.Path);
}
sb.AppendFormat(" {0}@{1}:\"{2}\"", session.Username, session.Host, EscapeForUnix(target.Path));
sb.AppendFormat(" {0}@{1}:\"{2}\"", session.Username, session.Host, target.Path);
}
else
{
if (source.Count > 1)
{
Log.WarnFormat("Not possible to transfer multiple remote files locally at one time. Tranfering first only!");
Log.WarnFormat("Not possible to transfer multiple remote files locally at one time. Transferring first file only!");
}
sb.AppendFormat(" {0}@{1}:\"{2}\" ", session.Username, session.Host, EscapeForUnix(source[0].Path));
sb.AppendFormat(" {0}@{1}:\"{2}\" ", session.Username, session.Host, source[0].Path);
sb.AppendFormat("\"{0}\"", target.Path);
}

return sb.ToString();
}

static string EscapeForUnix(string path)
{
return path.Replace(" ", @"\ ");
}


#endregion

#region RunPscp - Main work method
Expand All @@ -273,7 +268,7 @@ static string EscapeForUnix(string path)
/// <param name="inlineOutHandler">Inline handler for output</param>
/// <param name="inlineErrHandler">Inline handler for error</param>
/// <param name="successOutHandler">Handler for output of successful operation</param>
void RunPscp(
private void RunPscp(
PscpResult result,
string args,
string argsToLog,
Expand Down

0 comments on commit 618cc02

Please sign in to comment.