Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn O. Pearce2011-02-06 22:04:39 +0000
committerShawn O. Pearce2011-02-06 22:04:39 +0000
commit0180946bc885436be2d3c205c7444bcdd57d85cd (patch)
tree07044f949e0373bc24a46a62a9731960b55f79ab
parentc6423932bf466af76daf2cf38f37bc23cd16bf63 (diff)
downloadjgit-0180946bc885436be2d3c205c7444bcdd57d85cd.tar.gz
jgit-0180946bc885436be2d3c205c7444bcdd57d85cd.tar.xz
jgit-0180946bc885436be2d3c205c7444bcdd57d85cd.zip
Remove quoting of command over SSH
If the command contains spaces, it needs to be evaluated by the remote shell. Quoting the command breaks this, making it impossible to run a remote command that needs additional options. Bug: 336301 Change-Id: Ib5d88f0b2151df2d1d2b4e08d51ee979f6da67b5 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportGitSsh.java35
1 files changed, 3 insertions, 32 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportGitSsh.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportGitSsh.java
index e6609e6719..7ad5fc71c1 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportGitSsh.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportGitSsh.java
@@ -115,44 +115,15 @@ public class TransportGitSsh extends SshTransport implements PackTransport {
return new JschConnection();
}
- private static void sqMinimal(final StringBuilder cmd, final String val) {
- if (val.matches("^[a-zA-Z0-9._/-]*$")) {
- // If the string matches only generally safe characters
- // that the shell is not going to evaluate specially we
- // should leave the string unquoted. Not all systems
- // actually run a shell and over-quoting confuses them
- // when it comes to the command name.
- //
- cmd.append(val);
- } else {
- sq(cmd, val);
- }
- }
-
- private static void sqAlways(final StringBuilder cmd, final String val) {
- sq(cmd, val);
- }
-
- private static void sq(final StringBuilder cmd, final String val) {
- if (val.length() > 0)
- cmd.append(QuotedString.BOURNE.quote(val));
- }
-
String commandFor(final String exe) {
String path = uri.getPath();
if (uri.getScheme() != null && uri.getPath().startsWith("/~"))
path = (uri.getPath().substring(1));
final StringBuilder cmd = new StringBuilder();
- final int gitspace = exe.indexOf("git ");
- if (gitspace >= 0) {
- sqMinimal(cmd, exe.substring(0, gitspace + 3));
- cmd.append(' ');
- sqMinimal(cmd, exe.substring(gitspace + 4));
- } else
- sqMinimal(cmd, exe);
+ cmd.append(exe);
cmd.append(' ');
- sqAlways(cmd, path);
+ cmd.append(QuotedString.BOURNE.quote(path));
return cmd.toString();
}
@@ -178,7 +149,7 @@ public class TransportGitSsh extends SshTransport implements PackTransport {
final StringBuilder pfx = new StringBuilder();
pfx.append("fatal: ");
- sqAlways(pfx, path);
+ pfx.append(QuotedString.BOURNE.quote(path));
pfx.append(": ");
if (why.startsWith(pfx.toString()))
why = why.substring(pfx.length());

Back to the top